From: Void Singer
is that better than
list someList =["1", "2", "3", "4", "5", "6"];
llSay( 0, "die rolled: " + llList2String( llListRandomize( someList, 1), 0 ) );
Good question.
Let's compare what they have to do:
list data = ["Aniam", "Osgeld", "Tyken", "Jesse"];
integer list_length;
default
{
state_entry()
{
list_length = llGetListLength(data);//No use in making it check list length everytime
}
touch_start(integer total_number)
{
integer random = (integer)llFrand(list_length);
llSay(0, llList2String(data, random) + " is the Ruler of the forum!");
}
}
Makes the simulator do this with every touch:
"*** touch_start(1)
Frand(4.00000)=1.85173216920892
List2String([Aniam,Osgeld,Tyken,Jesse],1)=Osgeld"
list data = ["Aniam", "Osgeld", "Tyken", "Jesse"];
default
{
touch_start(integer total_number)
{
data = llListRandomize(data,1);
llSay(0, llList2String(data, 0) + " is the Ruler of the forum!");
}
}
The simulator does this:
*** touch_start(1)
ListRandomize([Aniam,Osgeld,Tyken,Jesse],1)=[Jesse,Osgeld,Aniam,Tyken]
List2String([Jesse,Osgeld,Aniam,Tyken],0)=Jesse"
So both do a good job. And with a short list probably equal But as the size of the list grows............Option one would be better because you are not having to manipulate the list itslf, which can be expensive when it comes to long lists.
A more clear example would be the link I posted above and compare what has to happen to get a random output:
list quotelist =[
"To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).",
"Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).",
"This above all: to thine own self be true. - (Hamlet, Act I, Scene III).",
"Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).",
"That it should come to this!. - (Hamlet, Act I, Scene II).",
"There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).",
"What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).",
"The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).",
"In my mind's eye. - (Hamlet, Act I, Scene II).",
"A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).",
"The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).",
"And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).",
"This is the very ecstasy of love. - (Hamlet, Act II, Scene I).",
"Brevity is the soul of wit. - (Hamlet, Act II, Scene II).",
"Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).",
"Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).",
"Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).",
"I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).",
"When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).",
"All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).",
"Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).",
"I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).",
"How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).",
"Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).",
"True is it that we have seen better days. - (As You Like It, Act II, Scene VII). "
];
default
{
touch_start(integer total_number)
{
integer quote = (integer)llFrand(24.0);
llSay(0, llList2String(quotelist, quote));
}
}
The simulator does this:
"*** touch_start(1)
Frand(24.00000)=15.7999644204043
List2String([To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).,Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).,This above all: to thine own self be true. - (Hamlet, Act I, Scene III).,Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).,That it should come to this!. - (Hamlet, Act I, Scene II).,There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).,What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).,The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).,In my mind's eye. - (Hamlet, Act I, Scene II).,A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).,The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).,And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).,This is the very ecstasy of love. - (Hamlet, Act II, Scene I).,Brevity is the soul of wit. - (Hamlet, Act II, Scene II).,Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).,Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).,Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).,I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).,When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).,All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).,Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).,I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).,How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).,Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).,True is it that we have seen better days. - (As You Like It, Act II, Scene VII). ],15)=Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I)."
list quotelist =[
"To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).",
"Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).",
"This above all: to thine own self be true. - (Hamlet, Act I, Scene III).",
"Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).",
"That it should come to this!. - (Hamlet, Act I, Scene II).",
"There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).",
"What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).",
"The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).",
"In my mind's eye. - (Hamlet, Act I, Scene II).",
"A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).",
"The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).",
"And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).",
"This is the very ecstasy of love. - (Hamlet, Act II, Scene I).",
"Brevity is the soul of wit. - (Hamlet, Act II, Scene II).",
"Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).",
"Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).",
"Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).",
"I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).",
"When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).",
"All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).",
"Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).",
"I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).",
"How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).",
"Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).",
"True is it that we have seen better days. - (As You Like It, Act II, Scene VII). "
];
default
{
touch_start(integer total_number)
{
quotelist = llListRandomize(quotelist,1);
llSay(0, llList2String(quotelist, 0));
}
}
The simulator has to do ALL of this:
"*** state_entry()
*** touch_start(1)
ListRandomize([To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).,Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).,This above all: to thine own self be true. - (Hamlet, Act I, Scene III).,Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).,That it should come to this!. - (Hamlet, Act I, Scene II).,There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).,What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).,The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).,In my mind's eye. - (Hamlet, Act I, Scene II).,A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).,The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).,And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).,This is the very ecstasy of love. - (Hamlet, Act II, Scene I).,Brevity is the soul of wit. - (Hamlet, Act II, Scene II).,Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).,Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).,Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).,I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).,When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).,All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).,Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).,I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).,How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).,Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).,True is it that we have seen better days. - (As You Like It, Act II, Scene VII). ],1)=[The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).,This is the very ecstasy of love. - (Hamlet, Act II, Scene I).,And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).,Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).,Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).,Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).,Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).,Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).,True is it that we have seen better days. - (As You Like It, Act II, Scene VII). ,I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).,To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).,In my mind's eye. - (Hamlet, Act I, Scene II).,The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).,All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).,I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).,There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).,Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).,When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).,This above all: to thine own self be true. - (Hamlet, Act I, Scene III).,How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).,Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).,What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).,A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).,That it should come to this!. - (Hamlet, Act I, Scene II).,Brevity is the soul of wit. - (Hamlet, Act II, Scene II).]
List2String([The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II).,This is the very ecstasy of love. - (Hamlet, Act II, Scene I).,And it must follow, as the night the day, thou canst not then be false to any man. - (Hamlet, Act I, Scene III).,Rich gifts wax poor when givers prove unkind. - (Hamlet, Act III, Scene I).,Do you think I am easier to be played on than a pipe? - (Hamlet, Act III, Scene II).,Blow, blow, thou winter wind! Thou art not so unkind as man's ingratitude. - (As You Like It, Act II, Scene VII).,Though this be madness, yet there is method in 't.. - (Hamlet, Act II, Scene II).,Neither a borrower nor a lender be; For loan oft loses both itself and friend, and borrowing dulls the edge of husbandry. - (Hamlet, Act I, Scene III).,True is it that we have seen better days. - (As You Like It, Act II, Scene VII). ,I will speak daggers to her, but use none. - (Hamlet, Act III, Scene II).,To be, or not to be: that is the question. - (Hamlet, Act III, Scene I).,In my mind's eye. - (Hamlet, Act I, Scene II).,The play 's the thing wherein I'll catch the conscience of the king. - (Hamlet, Act II, cene II).,All the world 's a stage, and all the men and women merely players. They have their exits and their entrances - And one man in his time plays many parts - (As You Like It, Act II, Scene VII).,I like this place and willingly could waste my time in it - (As You Like It, Act II, Scene IV).,There is nothing either good or bad, but thinking makes it so. - (Hamlet, Act II, Scene II).,Doubt that the sun doth move, doubt truth to be a liar, but never doubt I love. - (Hamlet, Act II, Scene II).,When sorrows come, they come not single spies, but in battalions. - (Hamlet, Act IV, Scene V).,This above all: to thine own self be true. - (Hamlet, Act I, Scene III).,How bitter a thing it is to look into happiness through another man's eyes! - (As You Like It, Act V, Scene II).,Can one desire too much of a good thing?. - (As You Like It, Act IV, Scene I).,What a piece of work is man! how noble in reason! how infinite in faculty! in form and moving how express and admirable! in action how like an angel! in apprehension how like a god! the beauty of the world, the paragon of animals! . - (Hamlet, Act II, Scene II).,A little more than kin, and less than kind. - (Hamlet, Act I, Scene II).,That it should come to this!. - (Hamlet, Act I, Scene II).,Brevity is the soul of wit. - (Hamlet, Act II, Scene II).],0)=The lady doth protest too much, methinks. - (Hamlet, Act III, Scene II)."