0 votes
by (260 points)
Hi there!

I am working on a notification system, where the player can save a reminder and he will be warned on that date and time, where a notification will appear in the sidebar. All of this using his real world date and time. My problem is to have Harlowe current-time working in Sugarcube2x and have it linked to a variable. Does anyone know how to make it work? I'm having a bad time figuring this out... Thanks for any help!

2 Answers

0 votes
by (159k points)
selected by
 
Best answer

SugarCube doesn't have built in Date/Time related functionallity, but you can use a JavaScript Date object to determine the current Date/Time on the end-user's machine.

<<set _now to new Date()>>

Year: <<= _now.getFullYear()>>
Month: <<= _now.getMonth()>>	(January is 0)
Day: <<= _now.getDate()>>
Hour: <<= _now.getHours()>>		(Midnight is 0)
Minute: <<= _now.getMinutes()>>
Second: <<= _now.getSeconds()>>


If you are looking for a set of widget for manipulating and displaying Date / Time information then I suggest you consider those written by the TheMadeExile here.

0 votes
by (44.7k points)

I have some Twine 2/SugarCube 2 time/date sample code which shows how to get the current time, add to the time, get the time remaining til some other time, show the time/date in various formats, and show whether an event is coming up shortly.

Hope that helps!  :-)

...