Cycle: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
m (Minor typo fix)
No edit summary
 
Line 5: Line 5:
Note that elements with the same cycle number do not necessarily execute on the same tick. The 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 <code>(CurrentTick mod Cycle) = (CurrentStatTicked mod Cycle)</code>. Note that <code>CurrentTick</code> is reset to a value of 1 whenever it exceeds 420 (not a joke), so elements with a cycle value greater than 420 will never update.
Note that elements with the same cycle number do not necessarily execute on the same tick. The 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 <code>(CurrentTick mod Cycle) = (CurrentStatTicked mod Cycle)</code>. Note that <code>CurrentTick</code> is reset to a value of 1 whenever it exceeds 420 (not a joke), so elements with a cycle value greater than 420 will never update.


The command '''#cycle''' will silently ignore non-positive values - that is, values smaller than 1.
== Syntax ==
 
<code>#cycle <value></code>
 
The value needs to be positive - values smaller than 1 will be ignored.


== Bugs and Quirks ==
== Bugs and Quirks ==

Latest revision as of 17:11, 29 September 2022

Cycle can refer to an element's cycle parameter (which dictates how often a statted element updates), or the ZZT-OOP command #cycle n (which sets an object's cycle parameter to n). An element with a cycle parameter of n updates once every 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 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 exceeds 420 (not a joke), so elements with a cycle value greater than 420 will never update.

Syntax

#cycle <value>

The value needs to be positive - values smaller than 1 will be ignored.

Bugs and Quirks

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