How to make events which could only happen once per day?

Twine Version: 2.4.0
Story Format: Sugarcube 2.36.1

I am using ChapelR’s cycle system but I am not able to implement events like ‘work in the store to earn money’ or 'talk with xyz’ because I only want the player to have the option to do these tasks once per day.
Could anyone help me please??
Thank you.

1 Like

I don’t know if there’s a more elegant way to do it, but I would create variables for those once-a-day tasks ($worked and $talked, let’s say) and make the displaying of those options conditional on that variable, like so:

<<if $worked == false>>
   <<link [[Work in the shop]]>>
      <<set $worked = true>>
   <</link>>
<</if>>

And then to make the variable reset every day, you’d put the following in the story JavaScript:

$(document).on(':cycle-change', function (ev) {
    if (ev.cycle.name === 'days') {
        State.variables.worked = false;
        State.variables.talked = false;
    }
});
3 Likes

Thanks a ton!

3 Likes