Twine Version: 2.3.16
Story Format: 2.36.1
I want to have a mechanic where once my character gets to a place they can rest, they can type in the numbers of hours they want to sleep for, then time passes and they go about their business.
Currently, I simply have 8 hours pass in the same location, but this won’t work in all situations.
<<button "Sleep">><<minutes_incr 480>><<goto "Room 23">><</button>> (8 hrs)
I tried amending an existing bank deposit/withdrawal code which pbparjeter helped me with…
Make a deposit/withdraw.
<<textbox "$change" "Enter amount">>
<<link "Withdraw">>
<<if $change lte $Bank>>
<<set $change to Math.trunc($change)>>
<<set $Gold += $change>>
<<set $Bank -= $change>>
<<replace "#sidebar_gold">><<print $Gold>><</replace>>
<<replace "#sidebar_bank">><<print $Bank>><</replace>>
<<endif>>
<</link>>
<<link "Deposit">>
<<if $change lte $Gold>>
<<set $change to Math.trunc($change)>>
<<set $Gold -= $change>>
<<set $Bank += $change>>
<<replace "#sidebar_gold">><<print $Gold>><</replace>>
<<replace "#sidebar_bank">><<print $Bank>><</replace>>
<<endif>>
<</link>>
It works perfectly for banking, so I changed what looked like might be the appropriate bits of code…
Get some sleep.
<<textbox "$sleep" "How many hours?">>
<<link "Sleep">>
<<set $sleep to Math.trunc($sleep)>>
<<set $minutes_incr += $sleep>>
<</link>>
…but it went about as well as you would expect, given I don’t know what I am doing It didn’t throw up any errors, it simply did nothing.
In my StoryInit, I have this (also from pbparjeter):
<<widget "minutes_incr">>
<<set $CurDate_inc to new Date(Math.trunc($CurDate) + $args[0] * 60 * 1000)>> <<set $CurDate to $CurDate_inc>>
<</widget>>
<<widget "check_date">>
<<set $CheckDateA to new Date($args[0])>>
<<set $CheckDateB to new Date($args[1])>>
<<if Math.trunc($CurDate) gte Math.trunc($CheckDateA) and Math.trunc($CurDate) lt Math.trunc($CheckDateB)>>
<<print $args[2]>>
<<endif>>
<</widget>>
In my StoryCaption, I have this:
Date: <<print $CurDate>>
And my button links look like this:
<<button "Go out">><<minutes_incr 30>><<goto "Town Centre">><</button>> (30 min)
This all works for the passage of time, so I was trying to tap into that.
Later, I will want to tie this to a fatigue variable, but one step at a time.