Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. string gsRndSeed = "asdf";
  2.  
  3. list glTest = [1,2,3,4,5];
  4.  
  5. integer RndInt(integer iMax)
  6. // Zero to iMax returned.
  7. // The gsRndSeed is used.
  8. // An initial value (of anything) can be set as the initial seed.
  9. // This gsRndSeed can be reset to produce the same set of random numbers again.
  10. {
  11. gsRndSeed = llSHA1String(gsRndSeed);
  12. integer i = (integer)("0x" + llGetSubString(gsRndSeed, 0, 7)) & 0x7fffffff;
  13. return i % (iMax + 1);
  14. }
  15.  
  16. list RandomizeList(list lInput)
  17. // This uses the RndInt function for randomizing.
  18. // Set gsRndSeed before coming in if you want to control the initial seed.
  19. // This uses swapping, so there's no guarantee that it will be the fastest method.
  20. {
  21. integer i;
  22. integer j;
  23. list l;
  24. integer iEnd = llGetListLength(lInput) - 1;
  25. //
  26. for (i = 0; i <= iEnd; i++)
  27. {
  28. j = RndInt(iEnd);
  29. l = llList2List(lInput, i, i);
  30. lInput = llDeleteSubList(lInput, i, i);
  31. lInput = llListInsertList(lInput, l, j);
  32. }
  33. return lInput;
  34. }
  35.  
  36. default
  37. {
  38. touch_start(integer total_number)
  39. {
  40. glTest = RandomizeList(glTest);
  41. llOwnerSay((string)glTest);
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement