1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

If condition problem

Discussion in 'Programming' started by zellface, Aug 31, 2017.

  1. zellface

    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?
    [​IMG]
     
  2. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    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.
     
  3. Tsa05

    Tsa05 Member

    Joined:
    Jun 21, 2016
    Posts:
    560
    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.
     
  4. The-any-Key

    The-any-Key Member

    Joined:
    Feb 2, 2017
    Posts:
    1,522
    +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.
     
  5. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    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.
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,037
    You mean inside brackets? So leaving out the brackets made it not happen?
     
  7. jo-thijs

    jo-thijs Member

    Joined:
    Jun 20, 2016
    Posts:
    2,844
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice