• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

String and Ds_Map

Ketsuni

Member
Okay, Basically, what I'm trying to do is the following:

I want to create a string that uses a variable in it.

The variable is stored inside a Ds_Map

When I try to run the game this happens:

___________________________________________
############################################################################################
FATAL ERROR in
action number 2
of Draw Event
for object Menu_Drawer:

DoAdd :: Execution Error
at gml_Object_Menu_Drawer_DrawGUI_2 (line 26) - draw_text(5+(line*7.5),5+(line*12),"Level: " + chosen[? "level"])
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_Menu_Drawer_DrawGUI_2 (line 26)

I don't think "line" is the thing giving problems, cause I already tested it without this line and it works.

So, what can I do to fix this problem?
 

Rob

Member
You have to use "string()" and put the numbers inside the brackets in order to draw numbers as text.

 

Ednei

Member
I'm using version 2.3 - beta.
I didn't understand what your code does.
Try this:

draw_text(5+(line*7.5),5+(line*12),"Level: " + string( chosen[? "level"] ) )
 

Ketsuni

Member
I'm using version 2.3 - beta.
I didn't understand what your code does.
Try this:

draw_text(5+(line*7.5),5+(line*12),"Level: " + string( chosen[? "level"] ) )
It draws a text at position 5+line*7.5 (x) and 5+ line * 12 (y) wich were supposed to say "Level: " and the player level
 

Yal

šŸ§ *penguin noises*
GMC Elder
For future reference, "DoAdd" errors means you're trying to add together two variables of different type (in this case, a string and a room ID). So if this happens again, check the types of all used variables on that line.

(same thing with DoAssign, DoMultiply, DoDivide and DoMinus)
 
Top