Page 1 of 1

[EOS] random text

Posted: Mon Jan 05, 2026 6:34 am
by kleeeee
Hi, newbie here. I don't have much experience in coding but trying to learn how to create a tease in the EOS editor. Is there a way to insert random text? I've seen other teases somehow set different teasing/edge lines in the init script and call them back during the tease itself but I'm having trouble understanding what they did. Help is appreciated!

Re: [EOS] random text

Posted: Mon Jan 05, 2026 9:28 am
by Thamrill
kleeeee wrote: Mon Jan 05, 2026 6:34 am Hi, newbie here. I don't have much experience in coding but trying to learn how to create a tease in the EOS editor. Is there a way to insert random text? I've seen other teases somehow set different teasing/edge lines in the init script and call them back during the tease itself but I'm having trouble understanding what they did. Help is appreciated!
I wrote a simple example tease whose script you can see here: https://milovana.com/webteases/geteossc ... 76607a5063

Basically, in the init script you create all possible options, like so:

Code: Select all

 cars = ["Saab", "Volvo", "BMW"]; 
for simplicty I hadded some code in the init functin that makes it easier randomly generate a number between 0 and max-1:

Code: Select all

function getRandomInt(max) {
  return Math.floor(Math.random() * max);
}
then before the say action you can call an eval function to define the text, like so:

Code: Select all

text=cars[getRandomInt(cars.length)]
this sets the text variable to one of the three possible values in the cars array (remember that value in an array are indexed from 0 to length-1)

Then, in the say action, you set the text to be variabe "text"

In principle, you can directly place "cars[getRandomInt(cars.length)]" in the say action, and skip the eval.

A practical way could be to create something like:

Code: Select all

 flavourChar1= ["Line 0", "Line 1", "Line 2", "Line 3"];
flavourChar2= ["Line 0", "Line 1", "Line 2", "Line 3"]; 
and then for character 1 set the text with:

Code: Select all

 flavourChar1[getRandomInt(flavourChar1.length)] 
and for character 2 set the text with:

Code: Select all

 flavourChar2[getRandomInt(flavourChar2.length)] 

Re: [EOS] random text

Posted: Mon Jan 05, 2026 3:14 pm
by kleeeee
thank you so much!