• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows [SOLVED] Not set Before reading it....?

W

Whiskey01

Guest
Hi guys i have a problem on game maker with a game that im working on.... and i keep getting an error tell me that i have not set a value before the program has read it , but i have.... maybe i did it wrong please help and reply ASAP


error:
global variable <unknown built-in variable>(-1610512733, -2147483648) not set before reading it.
at gml_Object_obj_Upgrade_5_DrawEvent_1 (line 1) - draw_text_transformed(view_xview[0]+32,view_yview[0]+544,"Cost: $" + (global.UpgradeCost2x) ,2.5,2.5,image_angle )

this is a draw event(the error is meant to be here?):

draw_text_transformed(view_xview[0]+32,view_yview[0]+544,"Cost: $" + (global.UpgradeCost2x) ,2.5,2.5,image_angle )


the place where i define the variable is in a game start event and this is what the game start event does:

global.UpgradeCost2x = 3000
 
Last edited by a moderator:
W

Whiskey01

Guest
global.UpgradeCost5
global.UpgradeCost2x
You're not calling it the same thing in the two events.
From what I can see you initialized global.UpgradeCost5 but then you used global.UpgradeCost2x try to change the game start to
Code:
global.UpgradeCost2x = 10000;
[EDIT]
Ninja'd by @Nallebeorn :p

Sorry i just copied the wrong thing,ive updated the post now.... anyone got any ideas?
 
W

Whiskey01

Guest
Try this code
Code:
draw_text_transformed(view_xview[0]+32,view_yview[0]+544,"Cost: $" + string(global.UpgradeCost2x) ,2.5,2.5,image_angle );
Convert the variable into a string using the string() function, Maybe this will help ?
just tried that but i still seemed to get the same thing...? i have no idea whats wrong.
 

Mazey

Member
Looks like the game start event isn't executing before you're trying to draw the text. Try putting global.UpgradeCost2x = 3000; in the room create code.
 
W

Whiskey01

Guest
Try to initialize it in the create event and see what happens... I never encountered this kind of bug after all these initializations, Try to clean caches, too.
i have put it in a create event before , but when i put the object in a different room it will then over right the value if it gets changed it will be put back to 3000. and i need it to change and save. I did work fine when i had this in a create event i dont get why changing it would create this problem.
 
W

Whiskey01

Guest
Looks like the game start event isn't executing before you're trying to draw the text. Try putting global.UpgradeCost2x = 3000; in the room create code.
where can i find the room create code?
 
W

Whiskey01

Guest
Create an object called obj_init and initialize the variables you need like the global.UpgradeCost2x = 10000; in the create event of it and make sure to check persistent checkbox in the object properties, Here is a screenie



The persistent checkbox if checked will make the variable initialized once in the very first room if it is exists there and it will over write the old variables only if it got called again, So make sure you put it in the very first room or wherever you wanted t to be initialized. This will totally help :)

Thank you worked, thank you to everyone that tried to help me.
 
Top