list/IronThrone = list("","","","","","")
IronThrone[1]=player;
for(var/i = 1; i<=6; i++)
if(i<=IronThrone.len)
while(!IronThrone[i] && i<IronThrone.len)
IronThrone.Remove(IronThrone[i])
// if(!IronThrone[i] && i==IronThrone.len)
// IronThrone.Cut(i,0)
Problem description:
IronThrone is a list 6 long. If I have a player in slots 2-6, then the above code trims out all unused slots, leaving a list 1 long with just the player in it.
If the player is in slot 1 (IronThrone[1]) then I get left with a list 2 long, with the player and 1 blank slot.
If I change the while() loop to
while(!IronThrone[i] && i<=IronThrone.len)
then I get a List Out Of Bounds error.
The only way to ensure I get a list just 1 long with just the player in is to uncomment the commented section.
My question is: why? This list 'arithmetic' is confusing me seriously. I'm glad I can get it to work, but I'd much prefer to know why.
while(IronThrone.Remove(null))
Also, you should ask yourself why you are getting empty spaces in lists in the first place.
You should not be forcibly deleting objects that you know are still in a list. If you can't know which lists the objects are in, you should be keeping track.
In fact, manual deletion of objects should almost never be done at all in DM, because it is insanely slow and often results in errors like the one you are attempting to solve.
Learn how garbage collection works and keep track of your references. You should never have to cull null references from your lists.