Howdy, Stranger!

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

Adding to a 'time' variable to indicate time passing? (Harlowe)

Hi, everyone. I've been working on a game recently where you are given a list of tasks you can do, and each task results in a certain amount of time being spent. When a certain amount of time passes, instead of being directed back to the list of tasks you go to another passage that takes place afterwards.
I'm doing this with a 'time' variable that is set in a previous passage like this:

(set: $time to 0)

then in each task passage, this is used to indicate time passes:

(set: $time to $time + 1)

but it comes up with an error stating I can't use the set variable to do this? Anyone know what I should use instead.
By the way, the part I'm using to move from the tasks bit to the passage after is this:

(if: $time > 3)[\
That's enough for today.->waiting
\]
(else:)[\
Back to work.->january
\]

But I think that works alright?

Comments

  • edited June 2016
    Please use the C button in the Comment fields tool-bar to wrap your code examples in code tags, it makes them easier to find/read/copy.

    Your example looks OK.

    I have included two sample Story Projects as attachments to a following reply, you can download them and then use the Import From File option in Twine 2 to add them both to your Story List:

    1. The Time Basic story includes code similar to your own except I initialized the $time variable within a startup tagged passage, it is a good idea to do the same with all your story's variables.

    2. The Time Advanced story automates the incrementing of the $time variable.

    It does this by using a header tagged passage named Task Tracker which looks to see if the passage about to be shown to the Reader has been assigned a task tag and if it has it increments the $time variable before displaying the passage.

    The story project also includes CSS in the Story Stylesheet area which hides the contents of the Task Tracker header.
  • The two attachments, do not mark this comment as an Answer or the forum software with eat them.
  • Thanks so much!!
  • im using Harlowe 1.2.3

    how do i add a variable? so each passage the time will change by 1 hour for example
  • edited March 2017
    nads96 wrote: »
    how do i add a variable?
    Both of the attached archive examples demonstrate how to initialise a $time variable within a startup tagged passage.

    nads96 wrote: »
    ...time will change by 1 hour for example
    A. Assuming that the $time variable represents the current hour.

    The Time Advanced shows you how to use a header tagged passage to run code every time passage traversal occurs. In your case you would remove the (if:) macro part and just keep the (set:) macro part. eg. replace the contents of the Task Tracker passage with:
    (set: $time to $time + 1)
    


    B. If on the other hand you want a more complex time system that tracks Days, Hours, Minutes, etc.... then you should looks at a thread like How to make a time system?, which was written for SugarCube but the theory could be implemented in Harlowe.
  • edited March 2017
    Thank you!

    How would i present the time so the person playing will know the time.
    So this is a variable..
    (set: $time to 9+1)

    I want it to say the time is 09:40
  • nads96 wrote: »
    How would i present the time .... (set: $time to 9+1) ... I want it to say the time is 09:40
    That method of tracking time only knows about hours.

    To track both Hours and Minutes (as well as Days and Months) I suggest you look at the more complex method I linked to in option B. of my previous comment.
Sign In or Register to comment.