[SOLVED]IF statement not working as expected.

Discussion in 'Programming' started by Chris Livermore, Oct 8, 2019.

Tags:
  1. Chris Livermore

    Chris Livermore Member

    Joined:
    Aug 1, 2019
    Posts:
    19
    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
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,409
    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.
     
  3. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    976
    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.
     
  4. samspade

    samspade Member

    Joined:
    Feb 26, 2017
    Posts:
    2,037
    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.
     
  5. Yal

    Yal GMC Memer GMC Elder

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

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,908
    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.
     
  7. Chris Livermore

    Chris Livermore Member

    Joined:
    Aug 1, 2019
    Posts:
    19
    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!
     
    ParodyKnaveBob likes this.

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