ID:140391
 
Code:
var/list/Attacks[][] = list(list()) //associated list with attack values and their targets
for(mob/char/C in attackers)
Attacks.Add(C.target)
Attacks[C.target][1] = C.movechoice
Attacks[C.target][2] = C.ratingchoice
Attacks[C.target][3] = C.locchoice


Callstack:
runtime error: cannot write to indexed value in this type of list
proc name: RunDuel (/combat_machine/proc/RunDuel)
usr: Bors (/mob/char/player/Bors)
src: /combat_machine (/combat_machine)




Problem description:
I am pretty sure I am getting the crash here.

If it's not apparent, my goal is to create a list of mobs that have previously been chosen as targets in the battle. Each mob reference on the list would point to a nested list with the three values in the order I chose above.

Thanks,

John

[Edit: Removed redundant code]

[Edit2:....and now I replaced the callstack I accidentally deleted in the last edit :-/]
You're forgetting one very important thing, you need to make the associated value a list before trying to set elements of it.

Attacks.Add(C.target)
Attacks[C.target] = list()
// Rest of stuff
In response to Nadrew
Nadrew wrote:
You're forgetting one very important thing, you need to make the associated value a list before trying to set elements of it.

Got it. Hey, are you trying to tell me my ghetto code is no good???

Ghetto Code:
var/list/Attacks[][] = list(list())
In response to BigJMoney
If it doesn't work then it's probably no good ;).
In response to Nadrew
One more little problem. Now I'm getting a list index out of bounds when I try to access the data. I'm doing this to test it:

world << "Attack against [Attacks[1]]:"    //this line works
world << "Move: [Attacks[1][1]]" //here I crash
world << "Rating: [Attacks[1][2]]"
world << "Location: [Attacks[1][3]]"
In response to BigJMoney
Yeah, I am noticing that referencing Attacks[1] is not the same as referencing Attacks[<mob reference>] even though the mob reference is the first item on the list. I get different values when I put either one into length().

Halp? I'm thinking maybe something can't be both a datum reference and a list at the same time? Because I notice there is also a difference if I assign Attacks[1] = list(x,y,z) and Attacks[<mob reference>] = list(x,y,z)
In response to BigJMoney
Nevermind, I just did things without using an assoc. list. I should still find an answer to this question about outer indexes being used as both lists and datum references at some point. Forum search is proving unhelpful in this regard :)