ID:139244
 
Code:
obj
newref
var/ctcl = list(0)
var/turnlist = list()
var/finallist = list()
var/a = 1
icon = 'icon.dmi'
icon_state = "clt"
Click()
for(var/mob/M in oview(10))
M.CT += 100
if(M.CT > 99)
ctcl +=M.CT
turnlist +=M

else
world << "not enough ct yet"

sort(ctcl)
world << "Complete: <b> sort complete"
//if(length(ctcl))
for(var/mob/M in turnlist)
if(length(turnlist))// if the list is not empty
if(M.CT == ctcl[1])
world << "match"
finallist += M
turnlist -= turnlist[1]
else
world << "empty"


Problem description: I'm trying to make a turn base system (that I understand) and this is what I've come up with however, it doesn't function as expected. It seems the turnlist never completely empties despite the turnlist -= turnlist[1].

Process I envisioned:

create list of mobs in the area
compare each mob's CT variable to 100
if it is 100, add mob's CT value to ctcl
sort all CT values in ctcl
order the mob's by comparing their CT value to the (now ordered) values in the ctcl list. (add to finallist)
mob in position 1 of finallist runs Action proc
position 1 of finallist is removed, next mob runs Action proc until the list is empty and process starts over.