Random text prompt
Posted: Wed Apr 10, 2024 6:10 pm
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?
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?