• 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!

Legacy GM [SOLVED]variable getting skipped in gm 1.4999999

E

EsraX

Guest
Hey there,

was wondering if anyone could help explain why the code below isn't working as i was expecting it to. I have tried work around like creating new sets of variables that dont use true/false but a numeric value but that runs into other problems.

What I expected the code to do is that whenever another object puts the variable global.basic_used as true, that each object would change itself into the next form until that variable is set to true again at which point it would change yet again. However it now instantly changes card_basic_2_obj into card_basic_1_obj instead of waiting for the variable to change again. It does however wait for the variable to change for the change of 4 to 3, and 2 to 1, so i am really lost as to what is wrong.

The code I wrote for each of the 4 objects is as follows
GML:
if global.basic_used=true
//in the steps event in the object initially creating when the room starts
{
    global.basic_used=false
    instance_change(card_basic_3_obj,true);
}
GML:
if global.basic_used=true
//so this is the object the previous object changes into
{
    basic_used=false
    instance_change(card_basic_2_obj,true);
}
GML:
if global.basic_used=true
//this would be the object where it instantaneously changes into the next one without me wanting it to 
{
    global.basic_used=false
    instance_change(card_basic_1_obj,true);
}
Code:
if global.basic_used=true
//last one, nothing special really. only difference is this time not an instance_change command but one to destroy itself
{
    global.basic_used=false
    instance_destroy();
}

P.S. all of these objects also have a create event setting their depth, nothing else.

Thanks to anyone reading this and sorry if i forgot to mention something important. (first post here and havent done any coding since highschool)
 

saffeine

Member
GML:
if global.basic_used=true
//so this is the object the previous object changes into
{
    basic_used=false
    instance_change(card_basic_2_obj,true);
}
basic_used=false

you forgot the global. , should be fine once you correct that.
 
E

EsraX

Guest
i feel like such an idiot now.
I legit spend 3 hours today reworking the code not once noticing i was missing global.
thank you so much Saffeine for saving my stupid brain from spending even more hours on it.
 
Top