Block time system for a newbei

Twine Version: 2.7.1
[Sugarcube]

Hello,

I am new at twine and I want to make a time system for my game. I look around for some time but I couldnt make it. I see some of them on this forum but I couldnt do it anyways. Anybody can help me out please ? And I am totally new on this so I just want a make a days and times like monday : morning - afternoon - evening - night-

I need a guide to understant for example:
Put this code on css
Put this code onjs
Put this on StoryInit
Put this on the StoryCaption to wiew the day and time.
And put this on your passage.to advange time…

I’m sorry to bother you, but I would really appreciate it if you could help me.

Kind Regards.

There are a handful Custom macros out there that deal with a time system. Namely:

Both have code to add to the JavaScript and documentation on how to use it (set it up, advance the time/date, display it, etc…)

1 Like

That’s too complex for me. English it not my main language. But thanks for the reply.

Chapel’s Cycle System would be the easiest out of the two, and often the one used in questions in this Forum…
AFAIK, there isn’t really an easier way aside from making it yourself from scratch (a.k.a. save a variable with the value being either morning, afternoon, evening, night - and change the value when needed).

1 Like

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

3 Likes

Thank you sir. I really appreciate you taking the time to help me. Have a greatful day. :heart::heart::heart: