Solved Trying to get 1/4th of entities in 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.

dreadmania

New Member
Nov 17, 2020
5
0
1
25
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:
 
set {_list::*} to "helo1", "helo2" and "helo3"
broadcast "%{_list::3}%" #should broadcast hello3
 
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::*}
 
That only gets one element. I don't think you read my post correctly, I'm trying to get a quarter of the list
 
Code:
for each entity in {zombielist::*}
    teleport loop-entity to a random location out of {corners::*}
#some function to destroy all zombie entities near one corner to destroy
#

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
 
Code:
for each entity in {zombielist::*}
    teleport loop-entity to a random location out of {corners::*}
#some function to destroy all zombie entities near one corner to destroy
#

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
Thank you!
 
Status
Not open for further replies.