It looks like you're new here. If you want to get involved, click one of these buttons!
<<nobr>><<silently>> <<if $UITimeRestart neq true or $mm lt 0>> <<set $mm to 0>> <</if>> <<if $UITimeRestart neq true or $hh lt 0>> <<set $hh to 0>> <</if>> <<if $UITimeRestart neq true or $h0 lt 0>> <<set $h0 to 0>> <</if>> <<if $UITimeRestart neq true or $m0 lt 0>> <<set $m0 to 0>> <</if>> <<if $UITimeRestart neq true or $ss lt 0>> <<set $s0 to 0>> <</if>> <<if $UITimeRestart neq true or $ss lt 0>> <<set $ss to 0>> <</if>> <<if $mm gte 60>> <<set $mm -=60>> <<set $hh +=1>> <</if>> <<if $mm gte 120>> <<set $mm -=120>> <<set $hh +=2>> <</if>> <<if $mm gte 180>> <<set $mm -=180>> <<set $hh +=3>> <</if>> <<if $mm gte 240>> <<set $mm -=240>> <<set $hh +=4>> <</if>> <<if $mm gte 300>> <<set $mm -=300>> <<set $hh +=5>> <</if>> <<if $mm gte 360>> <<set $mm -=360>> <<set $hh +=6>> <</if>> <<if $mm gte 420>> <<set $mm -=420>> <<set $hh +=7>> <</if>> <<if $mm gte 480>> <<set $mm -=480>> <<set $hh +=8>> <</if>> <<if $mm gte 540>> <<set $mm -=540>> <<set $hh +=9>> <</if>> <<if $mm gte 600>> <<set $mm -=600>> <<set $hh +=10>> <</if>> <<if $mm gte 600>> <<set $mm -=600>> <<set $hh +=10>> <</if>> <<if $mm gte 600>> <<set $mm -=600>> <<set $hh +=10>> <</if>> <<if $mm gte 600>> <<set $mm -=600>> <<set $hh +=10>> <</if>> <<if $mm gte 600>> <<set $mm -=600>> <<set $hh +=10>> <</if>> <<if $hh gte 24>> <<set $hh to 0>> <<set $Day +=1>> <</if>> <<if $hh gte 10>> <<set $h0 to "">> <</if>> <<if $hh lt 10>> <<set $h0 to 0>> <</if>> <<if $mm gte 10>> <<set $m0 to "">> <</if>> <<if $mm lt 10>> <<set $m0 to 0>> <</if>> <<if $ss gte 60>> <<set $ss -=60>> <<set $mm +=1>> <</if>> <<if $ss gte 60>> <<set $ss -=60>> <<set $mm +=1>> <</if>> <<if $ss gte 60>> <<set $ss -=60>> <<set $mm +=1>> <</if>> <<if $ss gte 60>> <<set $ss -=60>> <<set $mm +=1>> <</if>> <<if $ss gte 60>> <<set $ss -=60>> <<set $mm +=1>> <</if>> <<if $ss gte 120>> <<set $ss -=120>> <<set $mm +=2>> <</if>> <<if $ss gte 180>> <<set $ss -=180>> <<set $mm +=3>> <</if>> <<if $ss gte 240>> <<set $ss -=240>> <<set $mm +=4>> <</if>> <<if $ss gte 300>> <<set $ss -=300>> <<set $mm +=5>> <</if>> <<if $ss gte 360>> <<set $ss -=360>> <<set $mm +=6>> <</if>> <<if $ss gte 420>> <<set $ss -=420>> <<set $mm +=7>> <</if>> <<if $ss gte 480>> <<set $ss -=480>> <<set $mm +=8>> <</if>> <<if $ss gte 540>> <<set $ss -=540>> <<set $mm +=9>> <</if>> <<if $ss gte 600>> <<set $ss -=600>> <<set $mm +=10>> <</if>> <<if $ss gte 600>> <<set $ss -=600>> <<set $mm +=10>> <</if>> <<if $ss gte 600>> <<set $ss -=600>> <<set $mm +=10>> <</if>> <<if $ss gte 600>> <<set $ss -=600>> <<set $mm +=10>> <</if>> <<if $ss gte 600>> <<set $ss -=600>> <<set $mm +=10>> <</if>> <<if $ss lt 10>> <<set $s0 to 0>> <</if>> <<if $ss gte 10>> <<set $s0 to "">> <</if>> \\\\\\\\REPEAT CODE AS NECESSARY TO ALLOW FOR NUMBERS OUTSIDE OF MAXIMUM PRESET BRACKETS\\\\\\\\\ <<if $UITimeRestart neq true or $mm lt 0>> <<set $mm to 0>> <</if>> <<if $UITimeRestart neq true or $hh lt 0>> <<set $hh to 0>> <</if>> <<if $UITimeRestart neq true or $h0 lt 0>> <<set $h0 to 0>> <</if>> <<if $UITimeRestart neq true or $m0 lt 0>> <<set $m0 to 0>> <</if>> <<if $UITimeRestart neq true or $ss lt 0>> <<set $s0 to 0>> <</if>> <<if $UITimeRestart neq true or $ss lt 0>> <<set $ss to 0>> <</if>> \ <<if $UITimeRestart neq true>>\ <<set $UITimeRestart to true>>\ <</if>>\ <<if $mm gte 60>> <<set $mm -=60>> <<set $hh +=1>> <</if>> <<if $mm lt 0>> <<set $mm to 0>> <</if>> <<if $m0 lt 0>> <<set $m0 to 0>> <</if>> <<if $hh lt 0>> <<set $hh to 0>> <</if>> <<if $h0 lt 0>> <<set $h0 to 0>> <</if>> <</silently>><</nobr>> <b>$h0$hh:$m0$mm:</b>$s0$ss <<click "Seconds Time">><<goto "Time Test">><<set $ss += random (120, 180)>><</click>> \ <<set $UITimeRestart to true>>\
<<set $minutes to 0>> <<set $seconds to 0>> <<set $seconds to 300>> <<if $secondsover60 eq true>> <<set $seconds -=60>> <<set $minutes ++>> <<set $secondsover60 to false>> <<elseif $secondsover60 neq true>> <<if $seconds gte 60>> <<set $secondsover60 to true>> <</if>><</if>> <<if $seconds gte 60>> <<set $secondsover60 to true>> <</if>> There are $seconds seconds and $minutes minutes.
Comments
I'm not confident I understand what you're trying to do, but if you're trying to do what I think you are, why not something like:
Usage: If you're going to be changing the time a lot, you might want to just stick <<timeFormat>> in either your PassageDone or your PassageFooter special passage.
Here's a testing passage:
Obviously you'll want to change the variables to whatever works for you (make sure they're initialized before calling <<timeFormat>>).
I'm not sure if this is exactly what you're asking for; I didn't quite understand all of your code or why it was coded the way it was. Let me know if I missed something.
Give a look to this thread : maybe you will find what you need :
https://twinery.org/forum/discussion/3195/clocks-still-driving-me-nuts/p1
Have a good day.
Hey, I like that a lot! Thank you! I did a bit of fiddling with it myself and I can also translate it very easy to integrate with other macros, meaning it's a very effective system for what I'm attempting to do! Thank you very much!
I did notice whilst testing that this particular script will only work whilst using Sugarcube 2x.. Is there any possibility that a variation of this could be ported to work with sugarcube 1? I've been trying to leave the consideration of whether I want to transition or not till last seeing as how Sugarcube 2 makes some rather radical changes to the stylesheet (media screen, font, text size, layout, etcetera) along with other minute differences, so I haven't been all that keen to switch over just yet, largely in part due to the fact that I have so many other concerns; like all the systems that are currently not/only partially implemented as well.
As of now it merely adds the seconds without converting them to minutes when in sugarcube 1x. Last resort I will just revert to my long hand method again lol
Hey thanks for the link Alianna unfortunately it's not quite what I'm looking for because I require a more precise manner of timekeeping with more heavy emphasis on seconds and minutes; I'm even thinking of incorporating fractions of a second/milliseconds down the line!
I appreciate the link anyway, perhaps I may be able to use something from it down the line but due to the fact that it is javascript it would likely be taxing for me to try to integrate with other systems as well. But thank you anyway
I can't seem to get Twine 2 to load right now, so I can't test it, but I suspect it isn't working in SugarCube 1 because of the temp variable. Try changing _op to $op.
Sorry to hear about your twine not working! Tried that just now and no dice unfortunately, but what was interesting was that it seemed to be operating much the same in sugarcube 2x with both _ and $ prefixes tested individually.
Story variable? I'm not quite sure what might constitute as a story variable exactly.. What would be the difference in formatting from a temporary variable to a story variable?
You mean the system which keeps track of all the individual data throughout the story right? As long as time is affected by loading the game (reverting previous times etc) and the + seconds macro, then it shouldn't be too much of an issue unless it is DRASTICALLY different to the temp variable system, but as of right now I really have no idea.. It's the first time I've heard about such a dynamic as temporary variables/story variables to be honest.
I tested it in SugarCube 1.0.34, and it seemed to work exactly the same as the version written for 2.x.
Temporary variables (_var) are not tracked by the history system, meaning they only exist for the "turn" they are created for--usually meaning that a passage navigation unsets them. Having lots and lots of story variables ($var) can slow down your story as the history system will drag all of those variables (even ones you don't really need) and their values through the whole game. Generally, you don't want unnecessary variables clogging up the history.
For example, if you need to know if the player has been to the "circus" passage, instead of slipping a variable in that passage <<set $visitedCircus to true>> and then testing it later <<if $visitedCircus>>, you'd be better off using the visited() function:
Basically, it's a bad practice to create story variables you don't need. Temporary variables only last for the current moment in the history, though, so they're fine.
In this widget I used <<unset>> to prevent the story variable $op from being part of the history, which is functionally the same as using a temporary variable.
Yes.
During passage traversal a 'copy' of the state of all known story variables is made, the original story variable state is associated with the previous passage and added to the History system, and the 'copy' is made available to the passage about to be shown.
Bloody hell, this is beautiful! I'm not quite sure how the '$op' works in this sense.. How are the variables not being reset after every passage transition if the '$op' is being unset at the end of this script? I'm guessing it's probably my limited understanding of the math.trunc macros to be fair, heh, which brings me to the question of what even is the function of the $op in this circumstance?
Just trying to get a better understanding of the code involved so I can replicate something similar or truncate this system in the future. Thanks again for it by the way, seems to be doing the job!
And yes, truthfully I didn't replace the underscore with the dollar sign when I was testing as I wasn't sure as to whether the underscores where specifically set in place for that reason (but if the '$' function exactly the same as the '_' then what point is there in having both? I'm guessing there must be *SOME* difference besides keystroke..)
Interesting.. See I was not aware of this either, but It is definitely good that I now know. I've got a lot of $set variables in my story that are as simple as 'which response did you pick and here's the answer and it probably won't get brought up ever again' so this could be very useful provided I can get my number-blind head around it! I really can't thank you enough by the way, this has all been extremely useful!
So it really is simple as that? I've got plenty of them as well so maybe I shouldn't be so worried. Just seemed daft to have all those metaphorical taps running when they're no longer serving a purpose.
In this instance timekeeping will probably need to be a part of the history for the sake of loading the game, making sure variables are set in place, or even reverting the time back to a previous state if need be, so I think I will most likely need to remove that unset there. Going back to one of my previous posts, I'm still at a loss at how the $op variable even works atm lol
Ahh, thank you! Seems like the only things I don't really already know are the various different terminologies for each macros/script and/or how they're properly referred to. Nice. Good to know so that I don't make a fool of myself whenever I'm trying to sound like I know what I'm doing lol, but with coding it really is something I'm still not fully acquainted with yet.
Nice. Appreciate the detail! Thank you
I'm only using the _op and $op variables to store a bit of information to make the math more readable. I could instead write:
or something. It was just easier for my brain to stash that information, and I though it made it easier to understand. Clearly it did not do that latter part. _op/$op does nothing of consequence, and will get rewritten by new values as soon as the widget is called again anyway; you don't need that value to be stored.
Ahh. Thanks for clearing that up. I did a little bit of experimentation with the macros and managed to get it to work with milliseconds and even individual months! I suppose then that the <i>Math.trunc</i> is doing all the work? It's really quite impressive tbh, hopefully I will have mastered it soon but until then I'll probably just pick it up again when I need it.. Thanks again by the way
I'm not a master of Javascript, and in fact I'm very grateful that the code used in twine is simple macros, which seems to be a lot easier to understand and comprehend than doing all the coding longhand.. Perhaps one day I should delve a bit further to increase my understanding. Until then though I'll carry on trying to finish this thing heh.. Thanks again btw