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

[SOLVED]IF statement not working as expected.

C

Chris Livermore

Guest
ok I have a bit of a wierd one, ill let the picture do most the explaining.

upload_2019-10-8_13-1-14.png

How is the above possible?
if anyone has any idea, I have tried everything, rounding bother numbers, putting the logical test as a var before the IF (which also returns false, but the if still triggers on a false var) Im completely Lost and confused by how this code is executing :D
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You are seeing this in debugger because the breakpoint and execution line sit at the ds_list_add call, not after it. Add any other action after it so that you can pause there.
 

chamaeleon

Member
if anyone has any idea, I have tried everything, rounding bother numbers, putting the logical test as a var before the IF (which also returns false, but the if still triggers on a false var) Im completely Lost and confused by how this code is executing :D
I wouldn't make any assumptions here. I would just reach for show_debug_message(), output the two variables inside the "true" code block and let the program run and see what the output is. My guess you will never see an invalid result.
 

samspade

Member
I use the debugger a lot and I wouldn't assume that it is running unless you confirm that it does. The GMS 2 debugger often 'goes to'/highlights the next line without running it after things like continue, breaks, false if statements. I'm not sure why, but this is a visual thing in the debugger not an actual running of your code.

Looking at the debugger that data structure still is size 0. But The simplest way would be to put a break point on that line. You could also put a show_debug_message there if you want.
 

Yal

🐧 *penguin noises*
GMC Elder
I second show_debug_message, it's nice to get debug data in the background so you don't need to interrupt what you're doing constantly to see if it works as intended, but can check back after doing the entire thing.
 

TheouAegis

Member
Is this Studio 1 or 2? Just step to the next line if it's GMS2. But yeah, debug messages are often easier to sort through, since the console doesn't get cleared each step, meaning you can even spot patterns in bad code that seemingly works fine.
 
C

Chris Livermore

Guest
Hi Guys, thought I would let you all I know I was just being a noob and seeing it go to that line. Where infact it WAS NOT executing. Thanks for everyones replys!
 
Top