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

How to limit the inputs on a button's execution. Or maybe an alternative solution?

$
0
0
Hi All. I'll keep it brief.

I have a button that executes its contents, then goes on a 5 second "cooldown" before it can be clicked again. Part of its contents however is a <<repeat>> macro which basically subtracts 0.1s from the $cooldown variable every 100ms, replacing a text span that indicates how much time is left every 100ms as well.

The problem: I can spam click that button really fast, resulting in multiple <<repeat>> macros going off, and multiplying the subtraction so that it subtracts A LOT faster.

Is there a workaround to the problem, or am I coding this button the wrong way? Is there a more creative way of doing this? :(

The button is something like:

<<button "This goes on cooldown">>
<<if $cooldown > 0>>Do nothing
<<elseif $cooldown is 0>><<set $cooldown to 5>><<repeat 100ms>><<set $cooldown to $cooldown - 0.1>><<replace "#timer">>Cooldown: <<print $cooldown>>s<</replace>><</repeat>>
<</if>>

Viewing all articles
Browse latest Browse all 1844

Trending Articles