#How to make a list of all players sorted from closest to farthest

1 messages · Page 1 of 1 (latest)

floral lodge
#

^

heavy token
# floral lodge ^

Create two List<Player> Variable's, one called Unsorted Players, one called Sorted Players

You will need a loop for this to be instant, so lets use a For chip, and run from 0, to List Get Count, where the list in question is the players you want to sort from closest to furthest from X

Before running the For chip, set Unsorted Players to your player list (A copy of it if its from a variable or event), and set Sorted Players to a blank list, using a List Create with no inputs

When the loop is run, when Loop fires, get the closest person in Unsorted Players to your target, and add them to Sorted Players, after, remove that player from Unsorted Players

When Done fires, Sorted Players will return a list of all players in the initial list, sorted from closest to furthest

floral lodge
heavy token
floral lodge
#

yeah

violet helm
#

Idk, I would use a get all players, then use (however many player count is) get element chips then I would use the same amount of get distance chips then I would shove those in another list

#

Then I would sort that list

heavy token
violet helm
#

That doesn’t explode your cpu

#

It updates at without a for each

heavy token
violet helm
heavy token
#

Sometimes you need to use a For chip

heavy token
#

Also, instantly, your method is bad because its hard coded

You cant just get the element of every player, what if there is no player in that slot yet? you run into an index is out of range error

violet helm
heavy token
#

You are using more data then you have to for literally no reason

violet helm
#

And take that from the original list

heavy token
#

if you send a screenshot I can assure you im going to vomit

heavy token
heavy token
# floral lodge works like a dream <:IVoted:979159764573491300>

I have just realised a possible flaw in this system, and I bring a solution

Delete the For chip, replace with a Execution Integer Switch, with the outputs 0 and Failed
Failed = Loop
0 = Done
The Match should be the List Get Count of the Unsorted list variable

Connect the List Remove At execution output back into the Execution Integer Switch

This should function in theory the exact same way, but better and without possible bugs
It basically continues until there are no more items in the list, rather than executing once for each item in the intial list

floral lodge
heavy token
#

huh?

violet helm
#

Some random mind mapping map but this would be with two players, (otherwise you would just filter out the invalids)

heavy token
#

I can't even call that unoptimized because I dont even think that works even remotely

violet helm