• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Random text every X seconds

Status
Not open for further replies.
Level 5
Joined
May 13, 2013
Messages
165
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..
 
Level 5
Joined
May 13, 2013
Messages
165
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
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
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)
 
Level 2
Joined
Jun 11, 2013
Messages
9
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?
 
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)]
 
Level 2
Joined
Jun 11, 2013
Messages
9
^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).
 
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
 
Level 28
Joined
Sep 26, 2009
Messages
2,520
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)
 
Status
Not open for further replies.
Top