If condition problem

Z

zellface

Guest
heroBlocking variable is set to false for the whole time so why does it randomly jump to heroBlocking = false; and doesnt even check second condition?
 

jo-thijs

Member
heroBlocking variable is set to false for the whole time so why does it randomly jump to heroBlocking = false; and doesnt even check second condition?
Hello and welcome to the GMC!

I don't know why you're having that issue.
I tried to reproduce it, but failed.
It would be helpful if you could provide us with more details.
For example, what version of GameMaker are you using?
What buttons are you pressing in the debugger to make the jump you recorded?
How are you so sure heroBlocking is false?

In all likelyhood, this is just a visual glitch you're seeing in te debugger,
but the highlighted line resetting heroBlocking to false will not be executed.
 

Tsa05

Member
Visual Issue. The steppin has a tendency to skip to the last line within a code block when skipping the code block. So, in the case of your screenshot, either heroBlocking is false or image_index is not greater than imageNumber-1. Thus, the code is skipped. It *looks* like the last line in the block is being skipped to and executed, but it is not.
 

The-any-Key

Member
t *looks* like the last line in the block is being skipped to and executed, but it is not
+1
Set it to true there and check the watcher and you will notice that it won't change the variable to true. It's just a visual bug in the debugger. Nothing to worry about.
 

jo-thijs

Member
I've just been able to reproduce your issue.
It is like Tsa05 said, but I had to put the if-statements in the true-body of an if-then-else statement first,
otherwise the issue did not occur for me.
 

TheouAegis

Member
I've just been able to reproduce your issue.
It is like Tsa05 said, but I had to put the if-statements in the true-body of an if-then-else statement first,
otherwise the issue did not occur for me.
You mean inside brackets? So leaving out the brackets made it not happen?
 

jo-thijs

Member
You mean inside brackets? So leaving out the brackets made it not happen?
Brackets for the if-then-else statement?
Those are necessary to be able to have the nested if statements.
Brackets for the if-then statements inside the true-body of the is-then-else statement?
I left those away and got the same result as before.
 
Top