Solved Shuffle a list

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

pepper82

Member
Jan 26, 2017
272
1
18
41
Hi there,
I am trying to script a simple list shuffling function but for some reason it is not working and I hope somebody could post a sample script for this.

code_language.skript:
   loop {_list::*}:
       set {_ob} to a random object out of {_list::*}
       add {_ob} to {_shuffledlist::*}
       remove loop-value from {_list::*}

the lists look like this (white = original, pink = shuffled)
JoMxwls.png


in the pink list there are some entries (angel) missing and I have no clue why?
 
remove what?

and the shuffled - effect does not work for me (already tried). It sorts my list instead of shuffling it ... this is a bug which is fixed in a newer version of skript. But I am unable to update atm because of other bugs in newer versions
 
This isn't that hard, I think it goes something like this:
code_language.skript:
loop {_list::*}:
    set {_object} to a random object out of {_list::*}
    add {_object} to {_ShuffledList::*}
broadcast "%{_ShuffledList::*}%"

Whenever you loop through a list, it goes through each value in the
list already, so there is no need to remove it from the list, unless you
plan on deleting the list for some reason after.
 
  • Like
Reactions: pepper82
Status
Not open for further replies.