If you are requesting technical assistance with Twine, please specify:
Twine Version: Twine web and latest app just installed
Story Format: Sugarcube 2.x.x
Hello, first question here, i have read a couple of posts both here and on the reddit and more whilst searching on google but i am not sure how to ask, it’s probably something easy.
I plan to create a custom calendar/day night system, i use ChapelR Cycles custom macro, and at the end there’s a code for cycle-reset that i can’t quite seem to make work.
I have this on the javascript section of the story:
$(document).on(':cycle-reset', function (ev) {
if (ev.cycle.name === 'daynight') {
// increment day night
State.variables.totaldays + 1;
State.variables.weekday + 1;
}
});
Right below the // end cycles.min.js notation.
To display the date and cycle i use the storyCaption portion, it does display but it does not update, the variable does not change once the cycle resets.
And this is in the storyInit passage, it is properly set and the variables are shown as they were set.
<<set $totaldays to 1>>
<<set $monthday to 21>>
<<set $weekday to 1>>
<<set $numbermonth to 1>>
<<set $dayweek to "Sunday">>
<<if $numbermonth == 1>><<set $month to "June">>
<<elseif $numbermonth == 2>><<set $month to "July">>
<<elseif $numbermonth == 3>><<set $month to "August">>
<<elseif $numbermonth == 4>><<set $month to "September">>
<<elseif $numbermonth == 5>><<set $month to "October">>
<<elseif $numbermonth == 6>><<set $month to "November">>
<<elseif $numbermonth == 7>><<set $month to "December">>
<<elseif $numbermonth == 8>><<set $month to "January">>
<<elseif $numbermonth == 9>><<set $month to "February">>
<<elseif $numbermonth == 10>><<set $month to "March">>
<<elseif $numbermonth == 11>><<set $month to "April">>
<<elseif $numbermonth == 12>><<set $month to "May">>
<</if>>
<if $numbermonth gte 1 or $numbermonth lte 3>><<set $season to "Summer">>
<<elseif $numbermonth gte 4 or $numbermonth lte 6>><<set $season to "Fall">>
<<elseif $numbermonth gte 7 or $numbermonth lte 9>><<set $season to "Winter">>
<<else>><<set $season to "Spring">><</if>
<<newcycle 'daynight' 1>>
<<phase 'morning' 'midday' 'evening' 'night'>>
<</newcycle>>
<<if $weekday gte 8>>
<<set $weekday to 1>>
<</if>
<<if $weekday == 1>>
<<set $dayweek to "Sunday>>
<<elseif $weekday == 2>>
<<set $dayweek to "Monday">>
<<elseif $weekday == 3>>
<<set $dayweek to "Tuesday">>
<<elseif $weekday == 4>>
<<set $dayweek to "Wednesday">>
<<elseif $weekday == 5>>
<<set $dayweek to "Thursday">>
<<elseif $weekday == 6>>
<<set $dayweek to "Friday">>
<<elseif $weekday == 7>>
<<set $dayweek to "Saturday">>
<</if>
<<if $totaldays == 11>>
<<set $numbermonth == 2>>
<<set $monthday == 1>>
<<elseif $totaldays == 42>>
<<set $numbermonth == 3>>
<<set $monthday == 1>>
<<elseif $totaldays == 73>>
<<set $numbermonth == 4>>
<<set $monthday == 1>>
<<elseif $totaldays == 103>>
<<set $numbermonth == 5>>
<<set $monthday == 1>>
<<elseif $totaldays == 134>>
<<set $numbermonth == 6>>
<<set $monthday == 1>>
<<elseif $totaldays == 164>>
<<set $numbermonth == 7>>
<<set $monthday == 1>>
<<elseif $totaldays == 195>>
<<set $numbermonth == 8>>
<<set $monthday == 1>>
<<elseif $totaldays == 226>>
<<set $numbermonth == 9>>
<<set $monthday == 1>>
<<elseif $totaldays == 254>>
<<set $numbermonth == 10>>
<<set $monthday == 1>>
<<elseif $totaldays == 285>>
<<set $numbermonth == 11>>
<<set $monthday == 1>>
<<elseif $totaldays == 315>>
<<set $numbermonth == 12>>
<<set $monthday == 1>>
<</if>
I have seen other methods of using date and time, but my story sets place in a fictional world with a different year duration month names and the like, so it cant reflect current or real date/time.
I created the system to emulate our world calendar to be able to better spot issues during testing but once i check it works i would be changing them.
Thanks in advance.
Edit: there where some extra ’ when i pasted. Removed just in case.