Question about multiple "If" statements.

Discussion in 'RGSSx Script Support' started by tsukasa102938, Dec 15, 2013.

  1. tsukasa102938

    tsukasa102938 Villager Member

    Messages:
    10
    Likes Received:
    1
    So I'm rather new to scripting. Just really want to use it for damage formulas.

    Anyways, what I'm trying to do is have multiple "If" statements. I know about "Elsif", but that only gives me another different check. Is there a way to have many "If" statements? 
     
    #1
  2. kerbonklin

    kerbonklin Hiatus King Veteran

    Messages:
    1,728
    Likes Received:
    281
    First Language:
    English
    Primarily Uses:
    RMMV
    In programming you can structure IF conditions like so.

    1) Simple IF-THEN

    IF

      THEN

    END

    2) Nested IF-THEN

    IF

      THEN IF

        THEN IF

        END

      END

    END

    3) IF-ELSIF-THEN (Only uses one END)

    IF

      THEN

        ELSIF

          THEN

    END
     
    Last edited by a moderator: Dec 15, 2013
    #2
  3. tsukasa102938

    tsukasa102938 Villager Member

    Messages:
    10
    Likes Received:
    1
    Thanks for the quick reply. I don't think I worded my question correctly though and I apologize for that.

    What I'm trying to do is something along the lines of:

    IF

      RESULT

    IF 

      RESULT

    IF

      RESULT

    IF

      RESULT

    ELSE

      RESULT

    END

    Trying to do something along those lines of having more than three if statements. If I just do four "IF"s, it always result in 0. If I do multiple "ELSIF"s it also results in 0. If I just use one "IF" and use an "ELSIF" it works fine. Is there any other script command I can use to get that fourth or possibly more checks? 
     
    Last edited by a moderator: Dec 15, 2013
    #3
  4. Tsukihime

    Tsukihime Veteran Veteran

    Messages:
    8,230
    Likes Received:
    3,071
    Location:
    Toronto
    First Language:
    English
    You want all 5 branches to return the same result?
     
    #4
  5. Shaz

    Shaz Veteran Veteran

    Messages:
    37,914
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    If you want several conditions to be true, you do this:

    if condition and condition and condition resultendIf you want the same result when just one of a number of conditions is true, you do this:
    Code:
    if condition or condition or condition  return resultend
    If you want a different result depending on different conditions, you do this:
    Code:
    if condition1  result1elsif condition2  result2elsif condition3  result3else  result4end
    If you want the above, and all those conditions are similar (like you're checking the value of a variable, and want a different result depending on the variable), you do this:
    Code:
    case conditionwhen value1  result1when value2  result2when value3  result3else  result4end
    If none of those help, then you need to be more specific about what you're trying to do. Say what the conditions actually are that you're testing for, what the possible values are, and what the results are for each one. Explain what you're trying to achieve, not how you're doing it, and we can help you figure out the best way.
     
    #5
    Yato likes this.
  6. tsukasa102938

    tsukasa102938 Villager Member

    Messages:
    10
    Likes Received:
    1
    Those help me a lot. Thanks for the quick reply guys. Really appreciate it.
     
    #6
  7. Shaz

    Shaz Veteran Veteran

    Messages:
    37,914
    Likes Received:
    11,586
    Location:
    Australia
    First Language:
    English
    Primarily Uses:
    RMMV
    This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
     
    #7

Share This Page