If: Difference between revisions

From Wiki of ZZT
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...")
(No difference)

Revision as of 22:25, 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.), 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>