ID:170314
 
How would i pick a random phrase out of a list and have it be displayed to the entire world?

~>Jiskuha
Using the pick function.

var/list/phrases = list("phrase1","phrase2","phrase3") //make a list with the phrases.
var/randomphrase = pick(phrases) //create a new variable that chooses a random phrase from that list.
world << randomphrase
A better way would be
var/probables[]=list("prob1","prob2","prob3")
proc/pick_(list/l)
return l[rand(1,l.len)]
mob/verb/Test()
usr<<"ListPick:[pick_(probables)]"
In response to Angel_Inc
And why would that be better for this situation?
In response to DeathAwaitsU
DeathAwaitsU wrote:
And why would that be better for this situation?
it broadens the horizon of the code and eliminates sensless declarings of new vars :P
In response to Angel_Inc
Angel_Inc wrote:
DeathAwaitsU wrote:
And why would that be better for this situation?
it broadens the horizon of the code and eliminates sensless declarings of new vars :P

Heh. No seriously, what's the real reason?

Your pick_() proc does nothing that the real pick() does not. There's no reason to add it, and it doesn't "broaden the horizon" of anything.

As for senseless declarings, you wouldn't have to declare a new var to use pick() instead, and here you're just senselessly declaring a new proc you don't need.

Lummox JR
In response to Angel_Inc
If you are so worried about having to make a new var, couldn't you just use about the same thing you did?
var/list/phrases = list("hello","hi","nononono")
world << "[pick(phrases)]"

And wala, no need for a new var.

EDIT:This would also work..

var/list/phrases = list("hello","hi","nononono")
world << pick(phrases)
In response to XxDohxX
As hurt as I feel right now I will Maintain my integrity and pride
*Holds head high*but you guyz are righht.