Cycle: Difference between revisions

From Wiki of ZZT
Jump to navigation Jump to search
(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...")
 
(clarify ticking logic, add note on bounds check)
Line 1: Line 1:
'''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.
'''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 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 <code>#cycle 1</code> as the first line of ZZT-OOP in order initialize the object. External editors can modify the cycle parameter, usually rendering that code unnecessary.
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 <code>#cycle 1</code> 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 <code>(CurrentTick mod Cycle) = (CurrentStatTicked mod Cycle)</code>. Note that <code>CurrentTick</code> 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.
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 <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.


== Bugs and Quirks ==
== Bugs and Quirks ==
* Due to a division-by-zero error, cycle 0 [[Transporter|transporters]] will crash the game when rendered.
* Due to a division-by-zero error, cycle 0 [[Transporter|transporters]] will crash the game when rendered.


{{ZZT-OOP navbox}}
{{ZZT-OOP navbox}}

Revision as of 08:20, 8 February 2021

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

Bugs and Quirks

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