ID:168954
 
How should i go about listing players on a list by how fast their speed variable is? Like

Tazor 9
Hank 3
Jerry 5

So the list would order

Tazor
Jerry
Hank

How do i also bring up the person next in the list after each of them have finished their turn?
You'll need to use an associative list and then Bubble Sort it. Bubble Sorting is when you sort things according to how big they are, in this case it'll sort based on how high their speed is.

Here's a Bubble Sort proc that'll sort associative lists:

proc/Bubble_Sort(list/L)
for(var/x = 1,x <= L.len,x++)
for(var/remain = L.len,remain > 1,remain--)
if(L[remain-1] < L[remain]) //change this line to if(L[remain-1] > L[remain]) for ascending order.
L.Swap(remain - 1,remain)
return L


Your list will have to be like:

var/list/L = list("Tazor"=9,"Hank"=3,"Jerry"=5)
In response to DeathAwaitsU
where do i add in the speed variable to be sorted?
In response to Tazor07
Read what I said...

In a associative list.
In response to DeathAwaitsU
you will have ot explain everything or give me a link to a lib, ive never had to use lists before so its very vague
In response to Tazor07
In response to DeathAwaitsU
well what i have right now is a proc where it teleports people into a battle scene, then its regular rpg from there, how would i go about making the list in that proc?