ID:140082
 
Code:
mob/player/client
var
list/Achievements = list("First Blood" = 0,\
"Ten Shot Revolver" = 0,\
"One Hundred Bodys" = 0,\
"Zombie Slayer" = 0,\
"Fire in the hole" = 0,\
"Signed up" = 0,\
"Victory" = 0,\
"You Lose" = 0,\
"Level Up" = 0,\
"Level Ten" = 0,\
"Level One Hundred" = 0,\
"Out with the old" = 0,\
"In with the new" = 0,\
"Reload..." = 0,\
"F..F..F" = 0,\
"Medic!" = 0,\
"Sentry goin' up!" = 0,\
"Lazy Commander" = 0,\
"Burn Baby Burn" = 0,\
"Well Travelled" = 0)
(...)
proc/check_ach()
for(var/i = 20, i>0, i--)
var/ach_done = 0
if((src.Achievements[i]) == 1)continue
switch(src.Achievements[i])
(...)


Problem description:

I'm getting a runtime error stating bad index on if((src.Achievements[i]) == 1)continue. Mind shedding some light? I've tried searching 'Bad Index' but haven't gotten any useful topics.
The list is probably null at the time.

Also: src.Achievements[i] is going to give you a text string, not a number, so comparing it to 1 is silly.
In response to Garthor
I changed the line to if(src.Achievements[i] == 1)continue, which should remove the bad index error. It's now giving me a cannot read list error. =(
In response to Rushnut
Check to see which iteration (what the value of i is) it fails on. Also, as Garthor said, Achievments[i] is not a number.

Achievements[i] = "First Blood"
Achievements["First Blood"] = 0

But since Achievements[i] = "First Blood"...
Achievements[Achievements[i]] = 0

Which is kind of like
theAchievement = Achievements[i] // now equals "First Blood"
Achievements[theAchievements] // this is now equivalent to Achievements[Achievements[i]]
In response to Loduwijk

runtime error: cannot read from list
proc name: check ach (/mob/player/client/proc/check_ach)
source file: Acheivements.dm,57
usr: Rushnut (/mob/player/client)
src: Rushnut (/mob/player/client)
call stack:
Rushnut (/mob/player/client): check ach()
Rushnut (/mob/player/client): Stat()

Which is (Recently updated to be)
if((src.Achievements[src.Achievements[i]]) == 1)continue
In response to Rushnut
That is because you STILL haven't fixed the fact that the list is null. Or, alternatively, some sort of non-list.
In response to Garthor
How/why is the list null? O.o
mob/verb/Hi()
var/list/l = list("Cake" = 8, "Pie" = 2,"Milk" = 10)//since Cake is better than pie >:{
for(var/i=l.len,i>0,i--)
world<<"[l[i]] = [l[l[i]]]"


I believe 0 counts as 1 so 20 = 19 best to use l.len
In response to Leur
I think my programming is a little faulty, I have near enough that and it's not working.

Revised check_ach() proc
    proc/check_ach()
for(var/i = src.Achievement.len, i>0, i--)
var/ach_done = 0
if((src.Achievement[src.Achievement[i]]) == 1)continue
switch(src.Achievement[i])


Getting Cannot read list error.
In response to Rushnut
You haven't confirmed whether it's null or something else yet. My bet is that you used initial() to reset the list, which doesn't work right with compile-time lists.

Lummox JR
In response to Lummox JR
You put me onto the right track Lummox, thanks. My save was still using the old format for the list. :)
Although nothing to do with your problem, for aesthetics, you don't need to use slashes when doing lists that way. You'll find:
mob
verb
test()
var/list/a = list(
"myval" = 1,
"myval2" = 2,
"myval3" = 3,
"myval4" = 4
)

Will work just as well without the slashes.