A first shot at creating a set of widgets to help smooth time advancement in an open-world rpg I want to create. The general layout on the page is something like this:
<<nobr>>
<<set $advanceminutes to x>>
<<set $advancemonth to y>>
<<etc>>
<<advancetime>>
<</nobr>>
Page Text Goes Here
<<printtime>>
I'm having some issues with white space still, and I'm sure the code isn't as streamlined as it could be. Sorry it's kinda ugly, I'm new-ish to this xP
<!--Weekday Widget-->
<<widget weekday>><<nobr>><<if $weekday eq 1>>Mon<<elseif $weekday eq 2>>Tue<<elseif $weekday eq 3>>Wed<<elseif $weekday eq 4>>Thu<<elseif $weekday eq 5>>Fri<<elseif $weekday eq 6>>Sat<<elseif $weekday eq 7>>Sun<</if>><</nobr>><</widget>>
<!--Month Widget-->
<<widget month>><<nobr>><<if $month eq 1>>JAN<<elseif $month eq 2>>FEB<<elseif $month eq 3>>MAR<<elseif $month eq 4>>APR<<elseif $month eq 5>>MAY<<elseif $month eq 6>>JUN<<elseif $month eq 7>>JUL<<elseif $month eq 8>>AUG<<elseif $month eq 9>>SEP<<elseif $month eq 10>>OCT<<elseif $month eq 11>>NOV<<elseif $month eq 12>>Dec<</if>><</nobr>><</widget>>
<!--Season Widget-->
<<widget season>><<nobr>><<if $month gte 1 and $month lte 3>>Spring<<elseif $month gte 4 and $month lte 6>>Summer<<elseif $month gte 7 and $month lte 9>>Fall<<elseif $month gte 10 and $month lte 12>>Winter<</if>><</nobr>><</widget>>
<!--Time Advancement Widget-->
<<widget advancetime>><<nobr>>
<!--Advance Minutes-->
<<if $advanceminutes gt 0>>
<<set $minutes to $minutes + $advanceminutes>>
<</if>>
<<if $minutes gt 59>>
<<set $minutes to $minutes - 59>>
<<set $advancehour to $advancehour + 1>>
<</if>>
<!--Advance Hour-->
<<if $advancehour gt 0>>
<<set $hour to $hour + $advancehour>>
<</if>>
<<if $hour gt 24>>
<<set $hour to $hour - 24>>
<<set $advanceday to $advanceday + 1>>
<</if>>
<!--Advance Day-->
<<if $advanceday gt 0>>
<<set $day to $day + $advanceday>>
<<set $weekday to $weekday + $advanceday>>
<</if>>
<<if $day gt 30>>
<<set $day to $day - 30>>
<<set $advancemonth to $advancemonth + 1>>
<</if>>
<<if $weekday gt 7>>
<<set $weekday to $weekday - 7>>
<<if $weekday gt 7>>
<<set $weekday to $weekday - 7>>
<<if $weekday gt 7>>
<<set $weekday to $weekday - 7>>
<<if $weekday gt 7>>
<<set $weekday to $weekday - 7>>
<</if>>
<</if>>
<</if>>
<</if>>
<!--Advance Month-->
<<if $advancemonth gt 0>>
<<set $month to $month + $advancemonth>>
<</if>>
<<if $month gt 12>>
<<set $month to $month - 12>>
<<set $advanceyear to $advanceyear + 1>>
<</if>>
<!--Advance Year-->
<<if $advanceyear gt 0>>
<<set $year to $year + $advanceyear>>
<</if>>
<<set $advanceminutes to 0>>
<<set $advancehour to 0>>
<<set $advanceday to 0>>
<<set $advancemonth to 0>>
<<set $advanceyear to 0>>
<</nobr>>
<</widget>>
<!--Printing Widget>
<<widget printtime>>
<<print $hour>>:<<if $minutes lt 10>>0<</if>><<print $minutes>>
<<weekday>> <<month>> <<print $day>> <<season>> of <<print $year>>
<</widget>>
Edited because I accidentally left out a couple of the widgets. They're kind of important so I popped em in.
Comments
Once again all of you are great and this calendar looks brilliant- I love that you did seasons too...
You don't put widgets in the Story JavaScript, they go in a normal passage which should be tagged widget.
Sounds like saying English and English Subtitles aren't related, lol.
Thanks again Mad.
Modula arithmetic - - gives a 0-6 value, you can add 1 if you want. For integer division you need , so:
Arrays -
...assuming I've got the widget syntax right. Needs a 0-6 value for weekday.