Any: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
No edit summary
(document error, formatting)
 
Line 1: Line 1:
{{DISPLAYTITLE:any}}
{{DISPLAYTITLE:any}}
'''any''' is an internal flag in [[ZZT-OOP]]. When called, it scans the entire board for matching entities, and evaluates to true if at least one instance is found. '''any''' can detect anything with a [[ZZT-OOP name]], and a color argument can be specified as well.
'''any''' is an internal flag in [[ZZT-OOP]]. When called, it scans the entire board for matching entities, and evaluates to true if at least one instance is found. '''any''' can detect anything with a [[ZZT-OOP name]], and a color argument can be specified as well. If an invalid object kind is provided, '''any''' will throw a '''Bad object kind''' error.


'''any''' does not look beneath statted entities, so it's possible for it to miss things that are under objects, such as fake walls.
== Quirks ==
 
* '''any''' does not look beneath statted entities, so it's possible for it to miss things that are under objects, such as fake walls.


== Usage Example ==
== Usage Example ==

Latest revision as of 08:25, 8 February 2021

any is an internal flag in ZZT-OOP. When called, it scans the entire board for matching entities, and evaluates to true if at least one instance is found. any can detect anything with a ZZT-OOP name, and a color argument can be specified as well. If an invalid object kind is provided, any will throw a Bad object kind error.

Quirks

  • any does not look beneath statted entities, so it's possible for it to miss things that are under objects, such as fake walls.

Usage Example

This object changes its char graphic whenever there is at least one (bright) red gem on-screen.

@object
#cycle 1

:loop
#if any red gem char 2
#if not any red gem char 1
/i#loop

Note that any scans the entire board, so overusing it can be computationally intensive. Putting the /i in the code makes it so the object executes the loop only once per cycle, which helps avoid redundant any checks from wasting processing power.