Random Timer JS script.

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
FATALES
Explorer At Heart
Explorer At Heart
Posts: 256
Joined: Wed Oct 21, 2015 2:41 pm
Gender: Male
Sexual Orientation: Straight
Location: Slovakia

Random Timer JS script.

Post by FATALES »

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.
randomdsna.jpg
randomdsna.jpg (172.58 KiB) Viewed 1174 times
User avatar
edger477
Experimentor
Experimentor
Posts: 1114
Joined: Mon Nov 29, 2021 8:24 pm
Location: underfloor

Re: Random Timer JS script.

Post by edger477 »

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.
My estim creations: https://mega.nz/folder/73pxmBBQ#X6ylDzRafzTt9wanZ0dacw
And in E-Stim Index: viewtopic.php?t=27090

Try creating your own estims with my restim script generator!
Spoiler: show
You can also thank me with crypto: https://trocador.app/anonpay?ticker_to= ... e+a+coffee
kerkersklave
Explorer At Heart
Explorer At Heart
Posts: 709
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.

Post by kerkersklave »

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:

Code: Select all

items[Math.floor(Math.random() * items.length)]
Math.random() returns a number between 0 (inclusive) and 1 (exclusive) equally distributed. Math.floor() rounds down to the next integer.
spaisin
Explorer At Heart
Explorer At Heart
Posts: 139
Joined: Wed Sep 23, 2015 6:24 pm

Re: Random Timer JS script.

Post by spaisin »

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 .. :-)
FATALES
Explorer At Heart
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.

Post by FATALES »

fully functional:
randomtiem.jpg
randomtiem.jpg (187.93 KiB) Viewed 806 times
Post Reply