ID:139142
 
Code:
#define DEBUG

mob
var
list/party = new/list(0=" ", 1=" ", 2=" ", 3=" ", 4=" ", 5=" ")
mob/verb
TestCreation()
var/obj/Pokemon/_001/Bulbasaur = new()
var/i
src << "Party: [party]"
for(i=0, i < 6, i++)
var/o = party[i] //line 12
if(o == " ")
break
party[i] = Bulbasaur


Problem description:

I get the runtime error message:

runtime error: cannot read from list
proc name: TestCreation (/mob/verb/TestCreation)
source file: Mob.dm,12
usr: KingCold999 (/mob)
src: KingCold999 (/mob)
call stack:
KingCold999 (/mob): TestCreation()


Whenever I try to test the verb. It should look for an open position in the list (defined by a string with a single space in it) and then place the newly created object (Bulbasaur) into it. "src << "Party: [party]"" should output "Party: /list" and doesnt, even though the list is already created and defined to have 6 indexes (0-5).

The error appears BEFORE line 12 is even ran, as it shows up before "Party: " is outputted, which makes entirely no sense whatsoever to me.
BYOND lists start from 1, not 0, even if you defined 0 = "" it'll probably be index 1, either "0", I'm not exactly sure about this part.
Also lists are dynamic, instead of defining size you could simply add new values into it.
That shouldn't even compile. You cannot make an associative list with numerical indices.

However, in this case, there's no reason for it to be associative at all. Just make a list that's size 6 (var/list/party = new/list(6))
In response to Zaoshi
Thanks zao, because of you I figured it out =)

Changed all the numbers to string indexes (IE "0" instead of 0) and it works.

I always thought lists started at 0.. like arrays in other languages o.O

Oh well. One more step to completion >:D