Welcome to the Creatures Wiki! Log in and join the community.

ENUM

From Creatures Wiki
Jump to navigation Jump to search

ENUM is a CAOS command which controls flow.

Usage

Syntax: ENUM family (int) genus (int) species (int)

This marks the start of an enumeration loop, which must be ended by NEXT. It cycles through every agent which matches the classifier: first setting TARG, then evaluating the content of the loop, then going on to the next agent, and so on until all agents of the given class number have been exhausted.

Any or all of the arguments may be 0, which is a wildcard. So ENUM 0 0 0 will loop through all agents.

At the end of the loop, TARG is set to OWNR - so store the original TARG somewhere else if it's important.

A common CAOS error that can occur with ENUM is 'Invalid targ', if the TARG stops existing before the ENUM loop is finished counting. To avoid this, place the ENUM-NEXT loop pairing between an INST and a SLOW:

INST
ENUM blah blah blah..
*Do something here
NEXT
SLOW

Example

Destroy all badbugs:

ENUM 2 14 0
  KILL TARG
NEXT

Limit elasticity of all toys:

ENUM 2 21 0
  DOIF ELAS gt 50
    ELAS 50
  ENDI
NEXT

Age all creatures to adult:

ENUM 4 0 0
  SETV va00 4
  SUBV va00 CAGE
  DOIF va00 gt 0
    AGES va00
  ENDI
NEXT

Show the bounding boxes of everything:

ENUM 0 0 0
  DCOR 1
NEXT

Make ENUM stop counting after a certain number

See also

  • ESEE - 'visible' enumeration loop
  • ETCH - 'touching' enumeration loop
  • EPAS - vehicle's passengers
  • ECON - port connections