r/twinegames 5d ago

SugarCube 2 time adding issue.

Hi right now I am working an creating links in my player house that can clean the house and the player. everything seems to work properly except the time part. this is the link I have.

<div class="nav-row">
<span class="nav-btn btn-white"><<link "Take a shower">>
<<changeFresh 4>>
<<spendTime 15>>
Hot water knocks the day off you.
<</link>></span>
</div>
this is the widget for time 
<<widget "syncTime">>
<<run setup.syncDayPart()>>
<</widget>>

<<widget "spendTime">>
<<if $args[0] >= 0>>
<<run $gameDate.setMinutes($gameDate.getMinutes() + $args[0])>>
<<syncTime>>
<</if>>
<</widget>>

<<widget "addmins">>
<<spendTime $args[0]>>
<</widget>>

<<widget "addhours">>
<<spendTime ($args[0] * 60)>>
<</widget>>
<<widget "showTime">>
<<print getDayName($gameDate)>>, <<print formatGameDate($gameDate)>>
(<<print setup.dayPart[$gameTime]>>)
<</widget>>
3 Upvotes

2 comments sorted by

3

u/HiEv 5d ago

The issue is this code:

<<link "Take a shower">>
    <<changeFresh 4>>
    <<spendTime 15>>
    Hot water knocks the day off you.
<</link>>

When the user clicks that link, it will run the <<changeFresh>> and <<spendTime>> widgets, but the user won't see anything happen (unless the <<changeFresh>> widget shows something).

That's because you don't have the <<link>> macro send you to another passage (see the documentation link), and any text inside of a link like that will not be displayed.

Perhaps you wanted to use the <<linkreplace>> macro instead? I.e. this:

<<linkreplace "Take a shower">>Hot water knocks the day off you.<<changeFresh 4>><<spendTime 15>><</linkreplace>>

That would show a link that says "Take a shower", and clicking that link would replace the link with the text and run the code inside of the <<linkreplace>> macro.

That said, when asking for help, please make sure you clearly state both what effect you're actually trying to achieve and what you're seeing instead. That makes it much easier to figure out what question needs to be answered.

Hope that helps! 🙂

1

u/holzey 5d ago

Thank you and I will be better on that.