Howdy, Stranger!

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

How can I set a time in my story based on other variables?

I'm new to Twine so I don't know much here. I'm trying to have the sentence "It is X:XX in the morning." The time depends on another variable I have called $MinToAlarm. (The character woke up before the alarm and other things happen before the alarm goes off to make time pass.) Depending on what exactly the character has done, it changes what time it will be. I'm trying to use another variable called $time and using the (if:) macro but I think I'm doing something wrong because the sentence always ends up being "It is 0 in the morning." Please help if you can! I'm sorry if I sound naive. It's because in this subject, I am. Thank you!

Comments

  • Might be easier to help if you post your failing code snippet.

    Basically:
    time = AlarmTime - MinToAlarm 
    
    hours = time % 60
    mins = time - (hours * 60)
    
    "Time is " + hours + ":" + mins " in the morning."
    

    AlarmTime would need to be in minutes since midnight - so 7:30am would be 450. % is integer division - you might need a floor function to emulate it.
  • Thank you so much! So I would be able to use that time function throughout the rest of the story? Instead of having to use (set: $time to "X:XX") whatever time I want? Because that's what I ended up doing...I literally know nothing about coding or Twine. I'm taking a creative writing course and Twine is the platform we're using but I'd never heard of it before the class.
  • edited April 2016
    I'm trying to figure myself how to create a custom date/time system in Harlowe, and I made this to work by now. I'm very sure it's not the best way, but it's working for me...

    Basically, create three vars: hour, minute and day. Then use (if:) to check if minute is > than 59, so hour will increase 1. Same for hour: if > than 23, increase 1 day. When the minutes will pass it's up to you.

    My debug snippet:
    (set: $cday to 0)(set: $chour to 0)(set: $cminute to 0)
    (link-repeat: "Plus 1 minute →")[(set:$cminute to it + 1)]
    (link-repeat: "Plus 1 hour →")[(set:$chour to it + 1)]
    (link-repeat: "Plus 1 day →")[(set:$cday to it + 1)]
    
    {(live: 0.1s)[
    (if: $cminute > 59)[
     (set: $chour to it + 1)(set: $cminute to 0)
    ]
    (if: $chour > 23)[
     (set: $chour to 0)(set:$cday to it + 1)
    ] 
    $chour:$cminute h, $cday days.
    ]}
    
  • Oh that's cool! Great system. Thank you!
Sign In or Register to comment.