0 votes
by (200 points)
I'm learning Harlowe 3.0.1 and twine for the first time and I'm wanting a simple day cycle to advance from day 1 to day 2 and so on with a 12hr clock. The clock will advance with user actions, I am wanting a combat, stamina and health system to work hand in hand with it. With my little understanding so far my time test and a link repeat is not going so well, as the counting is increasing (as seen in my debug screen) but things won't update. With what little text based combat I have seen its a little overwhelming to really grasp a combat system. Sorry if this seems a little primitive but this is my time test so far.

--------------------------

(Time Advancement Test)

Passage: Time Code

Tag: header

Text:

(set: $hour to 0)(set: $min to 0)
(if: $min is 60)[(set: $hour to it + 1)(set: $min to it - 60)]
(else-if: $min > 60)[(set: $hour to it + 1)(set: $min to it - 60)]
                                                It is now $hour:$min

-----------------------------

(Time Advancement Test)

Passage: Test

Text:

Increase (link-repeat: "Time")[(set:$min to it + 15)]

-----------------------------

A friend has also had a crack at time as well with an end result failing and here is what she had.

-----------------------------

Passage: Timekeep

Text:

(if: $min is 60)[(set: $hour to it+1)(set: $min to $min-60)]
(else-if: $min > 60)[(set: $hour to it+1)(set: $min to $min-60)]
(if: $hour is 24)[(set: $hour to 0)]
(else-if: $hour > 24)[(set: $hour to 0)]
timekeep

------------------------------

Passage: ReRun

Text:

|timedisplay>[(display: 'timekeep')]

------------------------------

Passage: Start here

Text:

{(set: $hour to 11)(set: $min to 15)(replace: ?timedisplay)[(display: 'timekeep')]}
The hour is now:  $hour:$min

You are in a dark forest, you see a [[bear]]

-----------------------------

Passage: bear

Text:

{(set: $min to it+30)(replace: ?timedisplay)[(display: 'timekeep')]}
The time is now: $hour:$min

You fight the bear. You strike. It growls.  

[[GRRRRRR]]!!

-------------------------------

Passage: GRRRRRR

Text:

{(set: $min to it+30)(replace: ?timedisplay)[(display: 'timekeep')]
}
The time is now: $hour:$min

You have bested the bear and you are on your [[merry]] way.

----------------------------

Passage: merry

Text:

{(set:$hour to it+15)(replace: ?timedisplay)[(display: 'timekeep')]
}
You've had a wonderful sleep and it is now $hour:$min.

----------------------------

The time fails at the end going higher than 12hour and 60min.

any help is welcomed and thx in advance.

1 Answer

0 votes
by (530 points)
selected by
 
Best answer

Hello!

I'm no expert as I'm quite new to this but I've done something similar in one of my games so here's what I did:

From what I can see, your main problem is that the Time Code passage includes the (set: $hour to 0)(set: $min to 0) as this then automatically undoes any change you made to the variable in later passages.

I've just done a quick test in Harlowe 3.0.1 with the following code, which might be easier for you.

In the header passage with the header tag:

(if: $min is 60)[(set: $hour to $hour + 1)(set: $min to $min - 60)]
(else-if: $min > 60)[(set: $hour to $hour + 1)(set: $min to $min - 60)]
It is now $hour:$min

Then in the Start passage (the first one of the story) you should set the $min and $hour to the times you want the game on. I just did $hour as 2 and $min as 20 for my test.

Start passage:

(set: $hour to 2)(set: $min to 20)
[[start here]]

I then set it so that the Start passage (which could be your game title and a start button) has a no-header tag, and then put this in the CSS so that this passage doesn't show the header (as it shows the time of 0:0 because the variables haven't updated)

html.no-header tw-header {
	display: none;
}

Then in each passage where you want time to pass such as in the bear encounter, you'll just need to add on the hour or min that has passed.

(set: $hour to $hour+11)(set: $min to $min+15)

You are in a dark forest, you see a [[bear]]

When you follow the link to the next passage the time should have updated and be displayed automatically at the top of the page. It went above 12h and 60min with no problems. You may want to add in the conversion of 24 hours to one day in a new variable and add that into the 'The time is Xdays, Xhours, Xmins) for when you go over 24 hours.

 

I hope this helps, but let me know if anything doesn't work, or doesn't make sense.

The Tame Historian

by (200 points)
Cool thx, I ended up doing a passage altering when you visit each passage, which was simpiler than I thought. I also found out you can loop a passage by clicking a link with the name of the passage you are in to leave and come back triggering the code again. Worked out well if you needed to wait for a certain time.

thx for your help
...