# [Trigger]Random text every X seconds

#### Stare Cat

Level 5
Hello, I'd like to start off by saying that I'm a total nooblord when it comes to triggers. Anyway, I was wondering if there's a trigger that randomly picks between 10 numbers every 30 seconds and shows it?

Like, for every 30 seconds, tip number 2 shows up
Next 30 seconds, tip number 7 shows up
Next 30 seconds, another random tip shows up
and so on..

#### rulerofiron99

Level 25
Make a string array variable, let's call it Tip.

At map init, do
Set Tip[1] = "random text 1"
Set Tip[2] = "another random text"
Set Tip[3] = etc

In your periodic trigger, simply display Tip[random number between 1 and 10]

#### Stare Cat

Level 5
Make a string array variable, let's call it Tip.

At map init, do
Set Tip[1] = "random text 1"
Set Tip[2] = "another random text"
Set Tip[3] = etc

In your periodic trigger, simply display Tip[random number between 1 and 10]

Thanks!

EDIT: It doesn't randomly pick from the lists of Tips, it only shows one Tip and that depends on the number I put.
e.g
• Game - Display to (All players) the text: Tip[10]
it only shows Tip #10 every 30 seconds

#### rulerofiron99

Level 25
There's a function for a random number that you can use instead of putting a value (in your example 10)

#### Stare Cat

Level 5
There's a function for a random number that you can use instead of putting a value (in your example 10)

Math - Random?
seems like it

#### deathismyfriend

Level 29
ya math - random is the right one.

this is what it should look like

• Game - Display to (All players) the text: Tip[(Random integer number between 1 and 10)]

#### Nichilus

Level 21
You may want to create 10 different text strings, but you should choose random between 1-9; show picked message and swap that message with the 10th one.
This way you will never pick up same message, but still loop 10 random messages.
(i.e. the last shown message would always be set as 10th, and you would pick one message of the 9 other messages)

#### Maker

Level 37
Also make sure File -> preferences -> Test map -> use fixed random seed is unticked to enable random numbers to be generated.

#### icekiss

Level 2
1 > Define the Tip[Number] for each Tip you have.

2 > Every 30 secs Event should trigger some actions:
> Set an IntegerVariable as Random Number Between 1 and X (where X is the number of Tips you have)
> Game - Show Text for players as Tip[IntegerVariable].

Got it?

#### Maker

Level 37
^You don't need the integer variable

#### deathismyfriend

Level 29
1 > Define the Tip[Number] for each Tip you have.

2 > Every 30 secs Event should trigger some actions:
> Set an IntegerVariable as Random Number Between 1 and X (where X is the number of Tips you have)
> Game - Show Text for players as Tip[IntegerVariable].

Got it?

this is all Stare Cat needs.

• Game - Display to (All players) the text: Tip[(Random integer number between 1 and 10)]

#### icekiss

Level 2
^You don't need the integer variable

Actually i prefer to do such variable definitions in order to use the variable later if needed. (You always have the idea to use stuff later on while triggering so this is a way to do it lol).

#### deathismyfriend

Level 29
it is less efficient that way tho.

#### Nichilus

Level 21
Actually i prefer to do such variable definitions in order to use the variable later if needed. (You always have the idea to use stuff later on while triggering so this is a way to do it lol).
For this you don't need it; however if you wanted to prevent same message to appear twice, you would have to save that random number.

#### deathismyfriend

Level 29
For this you don't need it; however if you wanted to prevent same message to appear twice, you would have to save that random number.

u dont have to store it just do what u suggested earlier. change it from 1 to 9 and move the one selected to the 10 position and move the one in 10th position to the index that was used. for this u would need a tempInt

#### Nichilus

Level 21
I meant it like this:
• Actions
• Set i = (Random integer number between 1 and 9)
• Set String = Tip[i]
• Game - Display to (All players) the text: String
• Set Tip[i] = Tip[10]
• Set Tip[10] = String
• Set String = <Empty String>
To be able to swap last message and chosen message, I have to know which message I chose, hence why I save i (= temp integer)

#### deathismyfriend

Level 29
thats wat i meant to lol. one of us must of misunderstood lol sry about that.

Replies
1
Views
510
Replies
5
Views
767
Replies
4
Views
930
Replies
2
Views
682
Replies
2
Views
461