GML Help!

V

Violet_Lindsay

Guest
I am having troubles with coding. Currently I'm making a choose your own adventure type of game. While coding I ran into troubles, as you can see.
Here's the code:
show_message(" "+Name+" knew it would be dangerous, but "+Gender+" knew the outdoors very well.")

It says I have (Wrong type of arguments to +.)

what do I do? I really appreciate it,
Thank you!
 

Bentley

Member
Code:
" " // Gives you a space
+ Name // Gives you an error

show_message(" " + string(Name) + "etc
Can't combine the two.
 

Simon Gust

Member
Make sure Name and Gender are strings.
Strings are text values like "hello" or "55" as text.
If your values are numbers you will have to convert them first.

var name_text = string(Name);
and
var gender_text = string(Gender);

You can use these new variables in your text now.
 
V

Violet_Lindsay

Guest
Code:
" " // Gives you a space
+ Name // Gives you an error

show_message(" " + string(Name) + "etc
Can't combine the two.
Um i'm very new to this GML, I've only used it a handful of times. What can you do for "show_message"?

To be honest I've only watched 1 YT vid on it.
 
V

Violet_Lindsay

Guest
Make sure Name and Gender are strings.
Strings are text values like "hello" or "55" as text.
If your values are numbers you will have to convert them first.

var name_text = string(Name);
and
var gender_text = string(Gender);

You can use these new variables in your text now.
Thanks for the help
 

Bentley

Member
Um i'm very new to this GML, I've only used it a handful of times. What can you do for "show_message"?

To be honest I've only watched 1 YT vid on it.
show_message is really for debugging. You can middle mouse click any function to open up the manual to that function's page and it will explain what the function does.

Here's the problem with your code:

This is ok:
Code:
show_message("Hi, I'm Brandon");
This is ok
Code:
show_message(health);
but combind they are NOT ok. The code below throws an error.
Code:
show_message("Hi I'm Brandon and my health is " + health);
You can't mix a string with a real without converting the real to a string. Convert health to a string with the helpfully named function "string".
This is ok:
Code:
show_message("Hi, I'm Brandon, my health is: " + string(health));
 
Last edited:
V

Violet_Lindsay

Guest
show_message is really for debugging. You can middle mouse click any function to open up the manual to that function's page and it will explain what the function does.

Here's the problem with your code:

This is ok:
Code:
show_message("Hi, I'm Brandon");
This is ok
Code:
show_message(health);
but combind they are NOT ok. The code below throws an error.
Code:
show_message("Hi I'm Brandon and my health is " + health);
You can't mix a string with a real without converting the real to a string. Convert health to a string with the helpfully named function "string".
This is ok:
Code:
show_message("Hi, I'm Brandon, my health is: " + string(health));

Oh thank you so much!
 
Top