@FaRKLISIN
As requested, the following describes the steps needed to install, configure, and use Chapel’s Cycles System macro addon to implement a Day + Period “time” system.
1: Install the addon’s JavaScript code.
Open the Cycles System documentation (linked above), find the THE CODE label and click on the Minified, this will open another page showing the source code of the addon’s cycles.min.js
file. Use the Copy raw file toolbar button to copy the code into your clipboard, then paste that code into your project’s Story > JavaScript area.
2: Use the <<newcycle>>
in your project’s StoryInit passage.
to configure the require cycles.
The following code creates both a day and a period cycle.
<<newcycle 'day' 1 1 suspend>>
<<phase 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' 'Sunday' >>
<</newcycle>>
<<newcycle 'period' 1 1 suspend>>
<<phase 'Morning' 'Afternoon' 'Evening' 'Night'>>
<</newcycle>>
warning: the two cycles are not connected, so advancing the period
cycle past Night does not automatically cause the day
cycle to also advance. You will have to handle that situation yourself in your own code.
2a: [optional] Create a $days
Story variable in StoryInit to track the number days that have passed.
<<set $days to 1>>
note: This variable can be used when you want something to occur after a specific number of days have passed, or if an event (like a birthday) is meant to occur on a specific day.
eg. check if today is the 36th day of progress…
<<if $days is 36>>Don't forget to visit the Zoo today!<</if>>
3: Use the <<showcycle>>
macro in your project’s StoryCaption passage to display the current state of both cycles.
<<showcycle 'day'>>: <<showcycle 'period'>>
4: Use the <<editcycle>>
macro within your project’s Passage to advance a cycle.
eg. this following advances the period
cycle forward to the next stage, or loop it back to the 1st stage if the current stage is the last one in the sequence.
<<editcycle 'period' change 1>>
warning: as noted before, advancing one cycle has no affect on any other cycle. So advancing period
past Night
to Morning
will not cause the day
cycle to automatically advance.
You need to decide when to call the <<editcycle>>
macro, as only you know how & when your project progress from one period
to another and what causes the day
to advance. But those macro calls will likely be from the body of selected Links.
eg. a very basic “nap” link, that doesn’t care about proceeding past the end of the day.
<<link "Nap" "Have a nap">>
<<editcycle 'period' change 1>>
<</link>>
eg. a very basic “sleep” link, that resets the period
back to the 1st stage.
<<link "Sleep" "Start">>
<<editcycle 'day' change 1>>
<<editcycle 'period' reset>>
<<set $days += 1>>
<</link>>
5: Use the Cycle.check()
method to conditionally control when cycle changes occur.
eg. Determine whether the “Nap” or “Sleep” option should be shown, based on the current period
stage.
<<if Cycle.check('period', 'Night')>>
<<link "Sleep" "Go to sleep">>
<<editcycle 'day' change 1>>
<<editcycle 'period' reset>>
<<set $days += 1>>
<</link>>
<<else>>
<<link "Nap" "Have a Nap">>
<<editcycle 'period' change 1>>
<</link>>
<</if>>
The addon has many more features that you can read about in the documentation that was linked to at the start of this explanation, but the above should be enough to get you started.