How the Cycles System works
masterThe Cycles System allows you to introduce rotating states (like time of day, seasons, or days of the week) into your game. You define a cycle with a name, a list of values, and a turn interval. Every time a certain number of turns pass, the cycle moves to the next value in its list, eventually looping back to the start.
Key Behaviors
- Independent Tracking: Each cycle tracks its own turns independently. If you create a cycle mid-game, it starts its turn count from zero at that moment. To ensure cycles stay synchronized, it is recommended to declare all
<<newcycle>>macros in the same passage (e.g.,StoryInit). - Resetting/Overwriting: You can overwrite an existing cycle by calling
<<newcycle>>with the same name. Note that once a cycle is deleted via<<deletecycle>>or overwritten, it cannot be reclaimed. - Suspension: Instead of deleting a cycle you might need later, use
<<suspendcycle>>to freeze it in its current state. - Data Storage: Cycles are stored in a story variable (defaulting to
$cycles), making them compatible with SugarCube's built-in save/load system.
// Example of creating a synchronized time cycle
<<newcycle 'time' 'morning' 'noon' 'night' 5>>