any

From Wiki of ZZT
Revision as of 04:49, 8 February 2021 by RT-55J (talk | contribs)
Jump to navigation Jump to search

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 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.