1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Trying to get 1/4th of entities in a list

Discussion in 'Skript' started by dreadmania, May 9, 2021.

Thread Status:
Not open for further replies.
  1. dreadmania

    dreadmania New Member

    Joined:
    Nov 17, 2020
    Messages:
    5
    Likes Received:
    0
    So I'm trying to make a script that makes zombies go to random corners and then one of these corners will be destroyed. I have everything done except I don't know how to get a 1/4th of the entities in a list, and how to get a random corner. Could anyone help? Thanks! :emoji_slight_smile:

     
  2. Best Answer:
    Post #6 by Tymen van Essen, May 20, 2021
  3. Uzumaki

    Uzumaki Well-Known Member

    Joined:
    Feb 20, 2017
    Messages:
    310
    Likes Received:
    10
    set {_list::*} to "helo1", "helo2" and "helo3"
    broadcast "%{_list::3}%" #should broadcast hello3
     
  4. dreadmania

    dreadmania New Member

    Joined:
    Nov 17, 2020
    Messages:
    5
    Likes Received:
    0
    Not exactly what I'm asking for, the list has 250 entities
     
  5. Uzumaki

    Uzumaki Well-Known Member

    Joined:
    Feb 20, 2017
    Messages:
    310
    Likes Received:
    10
    set {_value1} to a random element out of {_list::*}
    remove {_value1} from {_list::*}
    set {_value2} to a random element out of {_list::*}
    remove {_value2} from {_list::*}
     
  6. dreadmania

    dreadmania New Member

    Joined:
    Nov 17, 2020
    Messages:
    5
    Likes Received:
    0
    That only gets one element. I don't think you read my post correctly, I'm trying to get a quarter of the list
     
  7. Tymen van Essen

    Joined:
    May 20, 2021
    Messages:
    43
    Likes Received:
    1
    Code (Text):
    1.  
    2. for each entity in {zombielist::*}
    3.     teleport loop-entity to a random location out of {corners::*}
    4. #some function to destroy all zombie entities near one corner to destroy
    5. #
    this will kill on average 25%, if you want to always end up with exactly 75% of zombies, you will have to add them to a list and ensure that no more than 25% of i is teleported to each corner.
    remember then to add a ceil() to ensure you have room for amounts that don't divide evenly in 4
     
  8. dreadmania

    dreadmania New Member

    Joined:
    Nov 17, 2020
    Messages:
    5
    Likes Received:
    0
    Thank you!
     
Thread Status:
Not open for further replies.

Share This Page

Loading...