20,741
edits
m (→Conditionals) |
mNo edit summary |
||
| Line 25: | Line 25: | ||
} | } | ||
</pre> | </pre> | ||
In both examples, the '''condition''' variable is just a placeholder, it could be a variable named '''condition''', but it could also be a more complex expression, such as a '''getprop''' call for example: | |||
<pre> | |||
var condition = getprop("/sim/signals/freeze"); | |||
if (condition) | |||
{ | |||
# true block, will be executed if condition is true | |||
} | |||
else { | |||
# false block, will be executed if condition is false | |||
} | |||
</pre> | |||
The same thing could be accomplished by using a call to getprop() as part of the condition: | |||
<syntaxhighlight lang="php"> | |||
if ( | |||
var condition = getprop("/sim/signals/freeze") | |||
) | |||
{ | |||
# true block, will be executed if condition is true | |||
} | |||
else { | |||
# false block, will be executed if condition is false | |||
} | |||
</syntaxhighlight> | |||
Note that you are never using the condition variable here, so you could also omit the whole declaration and directly use the getprop call: | |||
<syntaxhighlight lang="php"> | |||
if ( | |||
getprop("/sim/signals/freeze") | |||
) | |||
{ | |||
# true block, will be executed if condition is true | |||
} | |||
else { | |||
# false block, will be executed if condition is false | |||
} | |||
</syntaxhighlight> | |||
== Conditionals == | == Conditionals == | ||