Jump to content


Photo

Displaying text and variables on the same line


  • Please log in to reply
4 replies to this topic

#1 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 21 January 2012 - 04:55 AM

As the title says, how can I have text and a variable show on the same line when using show_message or draw_text? In C and C++, you simply use %d,%s,%c,etc with the appropriate variable type. In Java, you can do this
System.out.println("The value is " + myNumber + "!");
However, if I use "" + variable in GML, it gives me an error. I'm doing this for user-named INI files for saving and it would be nice to know this as well for the future.
  • 0

#2 ND4SPD

ND4SPD

    GMC Member

  • GMC Member
  • 2167 posts

Posted 21 January 2012 - 05:10 AM

What's your error?

You should be able to go string1+string2, or "string 1"+string2, or "string 1"+"string 2" or even "string 1" + string(number) + string 2!
  • 0

#3 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 21 January 2012 - 05:20 AM

___________________________________________
ERROR in
action number 1
of Mouse Event for Left Button
for object obj_save:

Error in code at line 1:
show_message("The number is " + global_control.bomb_gravity[bomb_number]);

at position 48: Wrong type of arguments to +.


  • 0

#4 TheouAegis

TheouAegis

    GMC Member

  • GMC Member
  • 4700 posts
  • Version:GM8

Posted 21 January 2012 - 05:51 AM

You need to use string(global_control.bomb_gravity[bomb_number])
  • 0

#5 goldsonic46

goldsonic46

    GMC Member

  • GMC Member
  • 581 posts

Posted 21 January 2012 - 05:57 AM

Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users