Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is there a way to access information from the player's system clock in SugarCube?

I'm using Twine 2 and am using SugarCube as Harlowe didn't seem to offer an elegant way of allowing text input from the player (which is a feature I need).

In my game I want to access the current date year on the player's system clock, but can't find a way to do it. WIth Harlowe, there's a (current-date: ) macro, but there isn't an equivalent with SugarCube from what I can tell?

Can anyone help?

Answers

  • So, here's the big "secret" about SugarCube. If you don't see a method for it, it's probably because there's a Javascript method for it. I highly suggest checking w3schools.com/js/default.asp.

    As for how to implement it in Twine 2, here is a rough and probably icky, but effective, example:
    <<print new Date().getHours()>>:<<print new Date().getMinutes()>>:<<print new Date().getSeconds()>>
    
    Placing this inside a passage produces a classic Hour:Minute:Second formatted time example. The Date object in JS has many more methods, and many more possibilities to it, so again, it's worth checking out the original documentation.

    Hope this helps!
Sign In or Register to comment.