Hi,
Ive been racking my brains for several hours with this thinking of different ways to do it without too much javascript as my skills with it are pretty basic.
I would like to count the turns using a variable $turns,so as per another post I know i can use <<set $turns to 0>> in the PassageReady. I already have the variable in my $player.turns so can reuse it. What I would like to do is for every lets say 20 turns set another variable $timeofday ["morning", "afternoon", "evening", "night"] and eventually also have seasons as a variable based on the amount of turns. I can figure out how to do the latter though I know its probably something basic I dont know how to count the amount of turns, I was thinking of lets say every 10 turns the $timeofday changes and every 200 the time of season changes. I am going to do these as widgets and add them to PassageReady/PassageDone
To add some more information the purpose is basic 2 different sets of text/actions occur depending on the time of day (the passages can be revisited), also random events will occur depending on time of day. In addition to this other factors such as health (health system already in place) will be effected depending on $season.
I am using Twine 2.1.1 and SugarCube 2.14
Any illumination on this would be greatly appreciated as I think if I can get this one figuered out it should cascade to the other few features I would like to implement.
Comments
You'll need to put this in your StoryInit:
Then, in PassageReady, invoke it with:
It uses passage tags for control. To stop the timer for a passage, tag it with "timePause." You'll need to tag one of your passages with "timeStart" to initialize the timer and get it counting. You can also use the "timeStart" tag to reset the timer to 0.
For the arrays, they'll accept any number of values and translate that into the code, so you can switch it to day/night by changing the value of the $timeofday array:
You can add more or less to each array as you see fit, the widget should be flexible enough.
Use the variables $displayTime and $displaySeason for output.
Really appreciated thanks
<<set _clockTime to Math.trunc($time / $dayLength)>>
_clockTime what is the reason for this underscore?, Is it to denote a temporary variable?
Yes. See TwineScript > Variables for more information.
Good catch. I was thinking since PassageReady was silent already it wouldn't matter, but there's no reason this widget couldn't be used in a PassageHeader or just a passage in general, so that's definitely a good idea.
Unless there's an even more pressing reason to do this even in a PassageReady that I'm not thinking of.
Yeah, I really, really couldn't think of how to do this. I knew it was unnecessary, but my brain just couldn't get there, haha. Thanks.
Awesome as always, TME.
I dont often ask for help on forums but I'm really glad I did ... really helpful thanks very much again.