• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Condition explanation please.

Status
Not open for further replies.
Level 6
Joined
Aug 15, 2007
Messages
209
Can someone give me the most efficient way to do a normal condition, an "and" condition, and an "or" condition? I saw one post that said you could just say 'return Condition 1 and Condition 2 and Condition 3. Please explain them to me. Thanks in advance! :piru:
 
Level 6
Joined
Aug 15, 2007
Messages
209
Err...

I forgot to ask that you make a simple example for me. When I convert from GUI to JASS, if gives me an IF, then, else, which I know isn't the best way. So can someone give me an example of the most efficient way to do it, so I can know where to put everything, like the paranthesis and stuff.
:thumbs_up:
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
[jass=K, simple example -- Life should be greater than 10]//Lame GUI way
function ThisIsACondition takes nothing returns boolean
if ( not ( GetWidgetLife(GetTriggerUnit()) > 10 ) ) then
return false
endif
return true
endfunction


//Proper way
function ThisIsACondition takes nothing returns boolean
return GetWidgetLife(GetTriggerUnit()) > 10
endfunction[/code]

This is talking about filters and trigger conditions, of course.
 
Last edited:
Level 11
Joined
Feb 18, 2004
Messages
394
a condition is a boolexpr. there are 2 sub-types a boolexpr, condition and filter. the diffrence is non-existant. Condition() will return the same output for the same input, thus you never have to destroy boolexprs as Condition() will always return the same handle for the same function input.

a boolexpr is a kind-of pointer to a function that returns boolean.

a statement like "if condition then" takes a boolean-logic expression. A boolean logic expression is any combination of boolean operators like == != >= <= < > and or, that equate down to a single boolean answer of true or false.

boolean operates take an operator and an operand. In other words, "boolean expression == boolean expression" this allows you to do things like "boolean expression == boolean expression and boolean expression"

in warcraft 3, boolean expressions are evaluated in a short circut manner. this means that if an answer can be infferd from the current execution, then the rest of the expression is not executed. example:
MyFuncReturnsTrue() or ThisFuncWillNeverBeExecuted()
this is due to the fact that the second function would not need to be executed in order to know the result of the expression, so why execute it? there is an order of operations in JASS, but mostly things are executed left-to-right, including brakets.

hope this explains everything...
 
Status
Not open for further replies.
Top