I don't know how to do it, it doesn't work. I don't know if the numbers can be less than 1000 ms.
It worked with random number generation but I don't want it.
Random Timer JS script.
- edger477
- Explorer At Heart
- Posts: 664
- Joined: Mon Nov 29, 2021 8:24 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: None of the above
- Location: Europe
Re: Random Timer JS script.
in eval for timer there should be 'random_item(items)' - that one will return integer value that can be used as duration
Last edited by edger477 on Thu Mar 17, 2022 9:30 am, edited 1 time in total.
-
- Explorer At Heart
- Posts: 556
- Joined: Sun Jul 06, 2014 2:11 pm
- Gender: Male
- Sexual Orientation: Open to new ideas!
- I am a: Slave
Re: Random Timer JS script.
So what you want to do, is randomly select one of the durations in items for the timer?
The eval-expression has to return a value in milliseconds, not a list of values, so you have to select the element yourself. Selecting an element randomly with equal distribution can be done like this:
Math.random() returns a number between 0 (inclusive) and 1 (exclusive) equally distributed. Math.floor() rounds down to the next integer.
The eval-expression has to return a value in milliseconds, not a list of values, so you have to select the element yourself. Selecting an element randomly with equal distribution can be done like this:
Code: Select all
items[Math.floor(Math.random() * items.length)]
Re: Random Timer JS script.
The image looks like you have just 'items' as the eval for the Timer? It seems you should be using random_item(items) instead - to actually call the function you've just created.
Although that relies on my non-eos-specific understanding of scopes, but ..
Although that relies on my non-eos-specific understanding of scopes, but ..
-
- Explorer At Heart
- Posts: 256
- Joined: Wed Oct 21, 2015 2:41 pm
- Gender: Male
- Sexual Orientation: Straight
- Location: Slovakia
Re: Random Timer JS script.
fully functional:
Who is online
Users browsing this forum: No registered users and 8 guests