Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string gsRndSeed = "asdf";
- list glTest = [1,2,3,4,5];
- integer RndInt(integer iMax)
- // Zero to iMax returned.
- // The gsRndSeed is used.
- // An initial value (of anything) can be set as the initial seed.
- // This gsRndSeed can be reset to produce the same set of random numbers again.
- {
- gsRndSeed = llSHA1String(gsRndSeed);
- integer i = (integer)("0x" + llGetSubString(gsRndSeed, 0, 7)) & 0x7fffffff;
- return i % (iMax + 1);
- }
- list RandomizeList(list lInput)
- // This uses the RndInt function for randomizing.
- // Set gsRndSeed before coming in if you want to control the initial seed.
- // This uses swapping, so there's no guarantee that it will be the fastest method.
- {
- integer i;
- integer j;
- list l;
- integer iEnd = llGetListLength(lInput) - 1;
- //
- for (i = 0; i <= iEnd; i++)
- {
- j = RndInt(iEnd);
- l = llList2List(lInput, i, i);
- lInput = llDeleteSubList(lInput, i, i);
- lInput = llListInsertList(lInput, l, j);
- }
- return lInput;
- }
- default
- {
- touch_start(integer total_number)
- {
- glTest = RandomizeList(glTest);
- llOwnerSay((string)glTest);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement