License from €75
DE EN FR ES IT CZ

Easiest way to check for multiple conditions

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 14 years ago
    Is there some way to check for multiple conditions at once? I wish to see if all levers are in correct positions and only then execute victory animations. For example:

    If "condition 1" is true & "condition 2" is true too
    then 
    
    else
    
    


    I have tried putting if sentences inside each other like this

    If "condition 1" is true
    If "condition 2" is true
    Play Awesome animations
    else
    else
    


    I have a faint idea that this might have to do something with me not understanding what is the difference between "else" and "end if" and in the way they work.

    Incase you decide to help me, thanks in advance.
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license. Forum readers get the Indie Bundle 15 % off with the code FORUM15: €84.15 instead of €99, valid until 31 Dec 2026.

    Get 15 % off Try it for free
  3. · 14 years ago
    are we talking Lua here or if else queries done via the editor?
  4. · 14 years ago
    Done via editor smile
  5. · 14 years ago
    hmm...
    ok dokie.

    You can create multiple IF whatever in a single query.

    if condition "one" is true
     if condition "two" is true
      if condition "three" if false
       ...
       do something
      else
       do something else
      endif
     endif
    endif
    


    same amount of endif as if!

    I prefer Lua because it's easier to write out & you can have as many queries as you like in a single sentence with only 1 if.
    also we can create complex queries thanks to the "and" & "or" functions smile

    if cond1 and cond2 and cond3 and not cond4 then
     -- do something!
    elseif cond4 then
     -- do something else
    end
    


    notice the not before cond4... this turns it into negative value (checks if cond4 is false)
    you can also use: if cond1 == true and cond4 == false etc.
  6. · 14 years ago
    Absolutely brilliant, thank you a lot!

    I still don't quite understand exactly what "endif" does codewise in comparison to "else". Understanding it would allow me more flexibility with using it ... ? (pretty please ^^ )
  7. · 14 years ago
    endif is used to close the if queries.

    for instance you can have multiple queries inside of a single if or inside of an action...

    if condition x is true
     if condition a is true then do something endif
     if condition b is true then do something endif
    else -- this is for doing something else if condition x is false
     do something else...
    endif
    


    if condition a then
     do something
    endif
    
    if condition b then
     do something
    else
     do something else
    endif
    


    in Lua: we can use "else" or "elseif" ...
    elseif is better because we only need to close with one end rather than one for each if.
    in the editor we only have "else".
  8. · 14 years ago
    Awesome stuff AFRLme, learning new stuff with Visionaire even 1,5 years since I started the project. Getting there, slowly, but getting there. Cheers once again!

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?