Random text prompt

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
User avatar
Full_Karma
Explorer
Explorer
Posts: 13
Joined: Thu Jun 30, 2022 7:11 pm
Gender: Male
Sexual Orientation: Straight
I am a: Submissive

Random text prompt

Post by Full_Karma »

Hi, I'm currently using a random text code in my web tease, and I would like to upgrade it,

Here is how it works :

var randomTextone = [
"random 1",
"random 2",
"random 3",
"random 4"
]
function randomTextoneFcn() {
return randomTextone [Math.floor(Math.random()*randomTextone .length)]
}

So one of the random text is picked and used when using "randomTextoneFcn()" in the Edit Eval Tag from the "Say" option.
Then I'll get multiple random texts by changing "one" to "two".

I would like to make the option to select 1 random text and not use it until all the random texts are used, one of my friends gave me this code :

var randomTextbegno = [
"random 1",
"random 2",
"random 3",
"random 4",
"random 5"
];
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array, array[j]] = [array[j], array];
}
}
function displayShuffledArray(array) {
shuffleArray(array);
array.forEach(item => console.log(item));
}
displayShuffledArray(randomTextbegno);

But I don't know how to make it work in the EOS editor. Any idea how to help me?
Nicely yours
kerkersklave
Explorer At Heart
Explorer At Heart
Posts: 555
Joined: Sun Jul 06, 2014 2:11 pm
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Slave

Re: Random text prompt

Post by kerkersklave »

Not sure about your friends code, but I would define a function like this:

Code: Select all

function remove(a, i) { return a.slice(0,i).concat(a.slice(i+1)) }
It is very basic javascript so should work in EOS. The function takes an array and removes the given element, returning a modified copy of the array. Call it like this:

Code: Select all

remove(array, 3)
You can use the code you have to select an element randomly and then remove it from the array. When you remove the last entry just restore it to the original version.
User avatar
Full_Karma
Explorer
Explorer
Posts: 13
Joined: Thu Jun 30, 2022 7:11 pm
Gender: Male
Sexual Orientation: Straight
I am a: Submissive

Re: Random text prompt

Post by Full_Karma »

I don't understand how I make it work. I tried but I don't get how it's done.
Nicely yours
User avatar
schefflera0101
Explorer At Heart
Explorer At Heart
Posts: 123
Joined: Wed Oct 07, 2020 12:21 pm
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Submissive

Re: Random text prompt

Post by schefflera0101 »

I have a layman's version (I'm sure it works better):
First you define your random prompts
and a variable for the used prompts:

Code: Select all

var randomTextone = ["random 1","random 2","random 3","random 4"]
function randomsay() {
return randomTextone[rnd];
}
var PrompUsed=[0,0,0,0]
Now the somewhat unfavorable part, because you need several pages for it:
Page1:
if
PrompUsed[0]+PrompUsed[1]+PrompUsed[2]+PrompUsed[3]==4
then
PrompUsed=[0,0,0,0] // set all prompts back to 0, if used.

rnd=Math.floor(Math.random()*randomTextone.length) //chooses random prompt.

//now the query whether it has already been used
if
PrompUsed[rnd]==1
then
Goto Page1
else
PrompUsed[rnd]=1
Goto Page2

Page2:
say: randomsay()

:love:
Try out my teases:
:love: Have fun! :love:

Older tease:
Edge slave training
User avatar
Full_Karma
Explorer
Explorer
Posts: 13
Joined: Thu Jun 30, 2022 7:11 pm
Gender: Male
Sexual Orientation: Straight
I am a: Submissive

Re: Random text prompt

Post by Full_Karma »

Yeah my next tease is already mostly finished, I can't use pages this way, but maybe for my next project, I'll use it.

Thanks anyway
Nicely yours
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests