Ifvar conditions: Difference between revisions
Hendricks266 (talk | contribs) No edit summary |
mNo edit summary |
||
Line 2: | Line 2: | ||
'''ifvarvar'''<'''conditional'''> <[[gamevar]]> <[[gamevar]]> | '''ifvarvar'''<'''conditional'''> <[[gamevar]]> <[[gamevar]]> | ||
Ifvar conditions are special [[if condition]]s that apply to [[gamevar]]s. These statements work by comparing the two inputs using the conditional provided as part of the command. If the resulting comparison or operation is true, the game will then execute the code specified. | Ifvar conditions are special [[if condition]]s that apply to [[gamevar]]s. These statements work by comparing the two inputs using the conditional provided as part of the command. If the resulting comparison or operation is true, the game will then execute the code specified. If only one CON command is to be performed, simply put it after the condition. For best reading, put it on the same line or on the following line, indented. For longer chains, enclose the code in curly braces ("{" and "}"). For performance reasons, do not use curly braces for single commands. [[Else]] statements can also be used. If you want to do nothing, followed by an else, in place of a command you can write <code>[[nullop]]</code> or <code>{ }</code>. | ||
{| {{prettytable}} | {| {{prettytable}} | ||
Line 48: | Line 48: | ||
|} | |} | ||
Since CON variables are integer-only, "less-than or equal to" (le, <=, ≤) and "greater-than or equal to" (ge, >=, ≥) conditionals are unnecessary. | Since CON variables are integer-only, "less-than or equal to" (le, <=, ≤) and "greater-than or equal to" (ge, >=, ≥) conditionals are unnecessary. As a shorthand you can drop the 'var' from the command and just use ife for ifvare, ifn for ifvarn, .etc | ||
{{varsuffix}} | {{varsuffix}} |
Revision as of 21:35, 1 August 2020
ifvar<conditional> <gamevar> <constant>
ifvarvar<conditional> <gamevar> <gamevar>
Ifvar conditions are special if conditions that apply to gamevars. These statements work by comparing the two inputs using the conditional provided as part of the command. If the resulting comparison or operation is true, the game will then execute the code specified. If only one CON command is to be performed, simply put it after the condition. For best reading, put it on the same line or on the following line, indented. For longer chains, enclose the code in curly braces ("{" and "}"). For performance reasons, do not use curly braces for single commands. Else statements can also be used. If you want to do nothing, followed by an else, in place of a command you can write nullop
or { }
.
Conditional | C/C++ | Math | Description | |
---|---|---|---|---|
e | == | = | equal to | |
l | < | < | less than | |
g | > | > | greater than | |
n | != | ≠ | not equal to | |
and | & | bitwise AND | ||
or | | | bitwise OR | ||
xor | ^ | bitwise XOR | ||
either | || | logical OR: either are non-zero |
Since CON variables are integer-only, "less-than or equal to" (le, <=, ≤) and "greater-than or equal to" (ge, >=, ≥) conditionals are unnecessary. As a shorthand you can drop the 'var' from the command and just use ife for ifvare, ifn for ifvarn, .etc
Commands with an additional "var" suffix take gamevars rather than constants or defined labels for their inputs. As an alternate short form, "varvar" can be dropped from these commands; for example ife serves an an alias for ifvarvare.