Page 1 of 1

Is there a way to set EOS timer based on a variable/user input

Posted: Sun Oct 25, 2020 3:02 pm
by cksfantasy
Hi All,

One other question today, with the Timers, i noticed that there is an Eval switch there, can someone give me one or two examples on how it can be used?

If i for example wanted to ask the user how much time he/she would like to be teased for, I'd like the timer to take that value and start the countdown.

Is this doable at all?

Thanks!

Re: Is there a way to set EOS timer based on a variable/user input

Posted: Mon Oct 26, 2020 12:37 pm
by Darigaaz
Prompt: variable = duration_in_s
Eval: duration_in_s = parseInt(duration_in_s)
Timer: eval = 1000 * duration_in_s

The best is to check that the user entered a number and not another string with a if isNan(duration_in_s) after the Eval

Re: Is there a way to set EOS timer based on a variable/user input

Posted: Mon Oct 26, 2020 1:29 pm
by cksfantasy
Darigaaz wrote: Mon Oct 26, 2020 12:37 pm Prompt: variable = duration_in_s
Eval: duration_in_s = parseInt(duration_in_s)
Timer: eval = 1000 * duration_in_s

The best is to check that the user entered a number and not another string with a if isNan(duration_in_s) after the Eval
Legend!! Thank you for that, you've made my day and i can confirm that this works well!

Re: Is there a way to set EOS timer based on a variable/user input

Posted: Mon Oct 26, 2020 2:00 pm
by Darigaaz
My pleasure !