Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

[Sugarcube] Tailored time system not functioning properly

$
0
0
Greetings,

Haven't been on in a while but for the most part I've been attempting to manage any problems I come across on my own, and it's been going reasonably well until this current juncture.

What I'm trying to do exactly is to convert a preset variable aka $Seconds, or something similar, into minutes. So 60 seconds would be equal to 1 minute 0 seconds, 90 seconds would be equivalent to 1 minute 30 seconds and 153 seconds would be converted to 2 minutes 33 seconds and so on, so forth. I'd prefer to do it in this manner rather than using javascript or anything else that I may have trouble integrating other systems with as essentially time will be the controlling factor in many game mechanic variables, from combat to disease incubation time to resting etc etc, so I would ideally want something that I can simply add + seconds or + minutes to any interaction and it will automatically translate onto the clock in the UI.

The following is an old draft of the code I had planned to use for this purpose.
<<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>>\

This is a draft of the time system I've been working on. I had to work around the fact that the <<repeat>> macro <b><i>still</b></i> would not function for me when:

A) I upgraded twine to the latest version
B) I tested the example provided by the sugarcube wiki with Twine 2 and using both Sugarcube 1x and Sugarcube 2x, whilst having to readapt the system to work with 2x

So I was forced to use a more long hand method, which is by no means effective AND to add insult to injury some values will not display properly, and I have no idea why. Today, I planned on restarting the whole system from the ground up because frankly this system is far too lengthy for something that sounds so ideologically simple on paper.

Today I've tried to circumnavigate the fact that the <<repeat>> macro does not seem to function properly with this instead:
<<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.

Which also does not function properly.

Would appreciate any input/help on this matter.

Viewing all articles
Browse latest Browse all 1844

Trending Articles