Randomizer?

I'm looking through all the scripts, and I don't see what I'm looking for. I'm just looking for a script that after a random number of turns, text is displayed. I can see triggers for set intervals, but that's not what I'm looking for.


Two ways to do this would be having a turnscript that runs every turn, doing something like:

if (RandomChance (20)) {
  msg ("Some text is displayed!")
  DisableTurnScript (this)
}

That would mean that once the turnscript is enabled, the event has a 20% chance of happening each turn.

Or you could do something like:

SetTurnTimeout (GetRandomInt (7,10)) {
  msg ("Some text is displayed!")
}

to pick a random number between 7 and 10 turns


So that first one is the one that I'm looking for, that looks awesome. If I set that to trigger in a room, will it keep running even if the player leaves the room? So, like, you enter a room, it triggers that turnscript and that just keeps running globally until I turn it off?


I think a turnscript in the room will only run as long as the player remains there. But if the turnscript is global (created from the game's "Scripts" tab), you can have a script in the room that enables it and it will stay enabled until the message has appeared.


Awesome. Now, if I wanted to get really crazy and have the randomizer choose a random string, can it also do that? The idea is basically a set of text strings that I want to randomly trigger throughout the game until the player reaches a point and the triggers stop.


So, I'm trying to also use a time-based randomizer, and I know that my syntax is wrong.

SetTimeoutID (GetRandomInt (15,20) "RandSpooks") {
PrintCentered ("COLD")
}

Obviously I'm getting a parameter error, but what is the proper randomizer syntaxz for time?


I think you're missing a comma between the time and the name


Now, if I wanted to get really crazy and have the randomizer choose a random string, can it also do that?

The most common way to pick a random string is to use the text processor. You can put something like {random:red:green:blue} in a message, and it will select one at random when it is displayed.

Or you can use PickOneString, which picks a random string from a stringlist.

msg ("The random colour is {random:red:green:blue} this time.")

or

msg ("The random colour is " + PickOneString (Split ("red;green;blue")) + " this time.")

That's great, thanks so much for your help.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums