If: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{DISPLAYTITLE:if}} '''if''' is a built-in ZZT-OOP command which evaluates the state of a flag, conditionally executing another command if it is true. '''if''' can te...") |
m (style) |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:if}} | {{DISPLAYTITLE:if}} | ||
'''if''' is a built-in [[ZZT-OOP]] command which evaluates the state of a [[flag]], conditionally executing another command if it is true | '''#if''' is a built-in [[ZZT-OOP]] command which evaluates the state of a [[flag]], conditionally executing another command if it is true. | ||
'''#if''' can test the status of internal flags ([[alligned]], [[blocked]], etc.), as well as a set of [[Set|user-assigned]] flags, of which ten can be active at a time. | |||
== Syntax == | == Syntax == | ||
<code>#if <flag> [then] <command></code> | <code>#if <flag> [then] <command></code> | ||
Notes: | Notes: | ||
* "then" is decorative and can be omitted. | * "then" is decorative and can be omitted. | ||
* The final command does not require a <nowiki>'</nowiki>#<nowiki>'</nowiki> symbol. | * The final command does not require a <nowiki>'</nowiki>#<nowiki>'</nowiki> symbol. | ||
== Chaining if Commands == | == Chaining if Commands == | ||
Multiple '''if''' commands can be chained together on one line to test more than one flag at once. The rightmost command will execute only when all preceding '''if'''s evaluate to true, similar to a logical AND operator in other languages. | Multiple '''#if''' commands can be chained together on one line to test more than one flag at once. The rightmost command will execute only when all preceding '''if'''s evaluate to true, similar to a logical AND operator in other languages. | ||
<code>#if <flag1> if <flag2> <command></code> | <code>#if <flag1> if <flag2> <command></code> | ||
{{ZZT-OOP navbox}} | {{ZZT-OOP navbox}} |
Latest revision as of 23:00, 8 February 2021
#if is a built-in ZZT-OOP command which evaluates the state of a flag, conditionally executing another command if it is true.
#if can test the status of internal flags (alligned, blocked, etc.), as well as a set of user-assigned flags, of which ten can be active at a time.
Syntax
#if <flag> [then] <command>
Notes:
- "then" is decorative and can be omitted.
- The final command does not require a '#' symbol.
Chaining if Commands
Multiple #if commands can be chained together on one line to test more than one flag at once. The rightmost command will execute only when all preceding ifs evaluate to true, similar to a logical AND operator in other languages.
#if <flag1> if <flag2> <command>
ZZT-OOP | |
---|---|
Prefixes |
|
Messages | |
Directions | |
Flags | |
Commands |