How do I stop an else if statement???

0 favourites
  • 10 posts
  • ok, so i have gotten everything working so far except for 1 glitch....so after completing a level, other levels start to unlock them selves and not just the next level as it should be, after debugging a lot i have noticed that since i have a nested if statement, my score criteria is meeting other conditions

    i.e if score > 1000 goto level 2

    if score > 2000 goto level 3

    and i score 2000, so first condition is met as well as 2nd,

    any way i can stop an if statement?

    http:// imgur.com/a/JJHVT

    you will notice other conditions like currentlevel as i was trying to fix the issue but it still persists.

  • Right click, add new condition.

    If score is > 1000

    And

    If score is < 2000

    Do action

    Or

    Name layouts "level 1,2,3 ect"

    On end of layout | system go to layout "level" & floor (score/1000)

  • Use Else.

    if level <= 1 ...

    Else if level <= 2 ...

    Else if ...

  • Right click, add new condition.

    If score is > 1000

    And

    If score is < 2000

    Do action

    Or

    Name layouts "level 1,2,3 ect"

    On end of layout | system go to layout "level" & floor (score/1000)

    hi, thanx but there are multiple condition that are met that's why the <1000 and >2000 wont work, creating level layout is like a last resort as i have 1 layout that im using for different levels, the conditions are what seperate the levels

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Use Else.

    if level <= 1 ...

    Else if level <= 2 ...

    Else if ...

    i am using the if else but if i'm on the first level and i score 2000, level 4 gets unlocked as the score condition for level 4 is also met.

  • Reverse the events and use else

    score > 4000

    ______ got to level 4

    Else

    score > 3000

    ______ got to level 3

    Else

    score > 2000

    ______ got to level 2

    Else

    score > 1000

    ______ got to level 1

    If 'score > 4000' then 'score > 1000' is also true, but it will not run.

    'Else' runs only if the previous condition(s) did not run.

  • Ok thanx but if you look at the screenshot, im actually checking the level firat then score, not only score but whether level is 1 or not, it finds highest score condition

  • Did you try this ?

    Use Else.

    if level <= 1 ...

    Else if level <= 2 ...

    Else if ...

    Put an 'else' in the blocks containing that 'Webstorage key ?" (except in the first one)

  • Did you try this ?

    > Use Else.

    >

    > if level <= 1 ...

    > Else if level <= 2 ...

    > Else if ...

    >

    Put an 'else' in the blocks containing that 'Webstorage key ?" (except in the first one)

    hi, thanx a lot, only reading now thou i tried the exact same thing, seems to work but will test it more extensively.

  • i have tried it and it actually works!!! thanxx for sharing a great post!!!!

    download Xmodgames app

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)