Cycle

From Wiki of ZZT
Revision as of 04:38, 8 February 2021 by RT-55J (talk | contribs) (Created page with "'''Cycle''' can refer to an element's '''cycle parameter''' (which dictates how often a statted element updates), or the ZZT-OOP command '''#cycle''' (which sets an object...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Cycle can refer to an element's cycle parameter (which dictates how often a statted element updates), or the ZZT-OOP command #cycle (which sets an object's cycle parameter). An element with a cycle parameter of n updates once ever n ticks. The exception is for elements with a cycle of zero, which never update themselves.

For objects placed with the default editor, the default cycle value is 3. Thus, for games made with the default editor, it is common to see #cycle 1 as the first line of ZZT-OOP in order initialize the object. External editors can modify the cycle parameter, usually rendering that code unnecessary.

Note that elements with the same cycle number do not necessarily execute on the same tick, the an element's index on the stat list is also a factor. The exact formula used to determine if a statted element executes on a given tick is (CurrentTick mod Cycle) = (CurrentStatTicked mod Cycle). Note that CurrentTick is reset to a value of 1 whenever it reaches 420 (not a joke), so elements with a cycle value of 420 or greater will never update.

Bugs and Quirks

  • Due to a division-by-zero error, cycle 0 transporters will crash the game when rendered.