if

From Wiki of ZZT
Revision as of 22:25, 8 February 2021 by Rbts (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.), and also 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>