Loop wont... Loop?

Discussion in 'RPG Maker MV' started by ParadoxLuckGames, Jan 1, 2019.

  1. ParadoxLuckGames

    ParadoxLuckGames Very Lucky Member

    Messages:
    29
    Likes Received:
    6
    First Language:
    English
    Primarily Uses:
    RMMV
    Simple if over age 13 too old back to number input screen if under 3 yrs old too young! Back to number input screen... However the loop is well.. ignored no matter what number is enter the loop breaks and keeps event moving not even a loop break added?

    Help.png
     
    #1
  2. OmnislashXX

    OmnislashXX Veteran Veteran

    Messages:
    583
    Likes Received:
    3,596
    Location:
    Maryland
    First Language:
    English
    Primarily Uses:
    RMMV
    I think that your Transfer Event is IN the Loop, therefore It's going to do just that.
     
    #2
  3. gstv87

    gstv87 Veteran Veteran

    Messages:
    1,674
    Likes Received:
    693
    First Language:
    Spanish
    Primarily Uses:
    RMVXA
    However, the loop is well. Ignored no matter what.
    However, the loop is well ignored, no matter what.
    However the loop is... well, ignored. No matter what number....

    which one is it?
     
    #3
    ParadoxLuckGames likes this.
  4. Isabella Ava

    Isabella Ava Veteran Veteran

    Messages:
    636
    Likes Received:
    751
    First Language:
    English
    It should be like this:
    Loop
    Input Number
    If Input Number >= 3
    If Input Number < = 13
    show Message "Well done! Let continue to do..."
    Break Loop
    Else
    Else
    Sorry but age must 3 < x < 13, please try again
    End Loop

    continue to run after this point if player input correct
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Not quite. If the age is over 13, nothing will happen.

    It should be like this:

    Code:
    Loop
      Input Number
      If Number < 3
        Too Yount
      Else
        If Number > 13
          Too Old
        Else
          Okay, let's do this
          Break Loop
        End
      End
    End Loop
    
    Transfer
    
     
    #5
    ParadoxLuckGames likes this.
  6. ParadoxLuckGames

    ParadoxLuckGames Very Lucky Member

    Messages:
    29
    Likes Received:
    6
    First Language:
    English
    Primarily Uses:
    RMMV


    This is correct thank you however i have a question i suppose about the code structure itself... why must If number < 13 be in the first ones 'Else' line? couldn't it be

    If
    var a = 1
    var b = 2
    var c = 3
    eat the cheese

    else throw the cheese
     
    #6
  7. ParadoxLuckGames

    ParadoxLuckGames Very Lucky Member

    Messages:
    29
    Likes Received:
    6
    First Language:
    English
    Primarily Uses:
    RMMV
    Yes
     
    #7
  8. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    Because if it is less than 3, then it cannot also be greater than 13, so that line would never be executed unless it was in an Else block.
     
    #8
    ParadoxLuckGames likes this.
  9. ParadoxLuckGames

    ParadoxLuckGames Very Lucky Member

    Messages:
    29
    Likes Received:
    6
    First Language:
    English
    Primarily Uses:
    RMMV
    Fatality...
     
    #9
  10. Shaz

    Shaz Veteran Veteran

    Messages:
    37,184
    Likes Received:
    11,053
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    You cannot do
    If
    var a = 1
    var b = 2
    var c = 3

    You have to do 3 conditional branches.

    Code:
    If var a = 1
      If var b = 2
        If var c = 3
    Then what happens if var b is 2 and var c is 3, but var a is not 1? The second and third tests will never be performed, because the first one is not true.

    However you are not checking 3 different variables. You are checking one variable for different values. The rules still hold though - if the tests are mutually exclusive (if age < 3, then age cannot be > 13, and if age > 13, then age cannot be < 3), so you can't nest the conditions, because if the first one is true, the second one will never be, and if the first one is false, the second condition will never be tested.
     
    #10
  11. ParadoxLuckGames

    ParadoxLuckGames Very Lucky Member

    Messages:
    29
    Likes Received:
    6
    First Language:
    English
    Primarily Uses:
    RMMV



    Thank you now i understand on a higher lvl :)
     
    #11

Share This Page