ID:145788
 
Code:
obj
arrow
icon = 'arrow.dmi'
var/command
var/mob/monsterselected
var/spellchoice
var/cursor_x = 0; var/cursor_y = 0
var/list/menu[0][0]

proc/North()
if(cursor_y > 1)
cursor_y -= 1
else if(cursor_y <= 1)
var/list/L = menu[1]
cursor_y = L.len
screen_loc = menu[cursor_x][cursor_y]

proc/South()
var/list/L = menu[1] // Line 19
if(cursor_y > L.len)
cursor_y += 1
screen_loc = menu[cursor_x][cursor_y]

proc/East()

proc/West()

mob
proc
MakeArrow(mob/player/P,x2,y2)
var/client/C = P.client
var/obj/arrow/arrow = new /obj/arrow
arrow.layer = MOB_LAYER + 2
arrow.screen_loc = "[x2],[y2]"
C.screen += arrow
P.arrows = arrow
P.arrows.command = 0

CommandText(mob/player/P,mob/monsters/M,list/monstergroup)
for(var/obj/O in P.textlist)
del(O)
var/client/C = P.client
for(var/obj/arrow/A in P.client.screen)
del(A)
if(P.arrows)
del(P.arrows)

P.arrows.menu = new/list(1,5)
P.arrows.menu[1][1] = "1,13"
P.arrows.menu[1][2] = "1,12:2"
P.arrows.menu[1][3] = "1,11:5"
P.arrows.menu[1][4] = "1,10:7"
P.arrows.menu[1][5] = "1,9:9"


Problem description:
When I hit client/North() or client/South(), which will redirect to the obj's North/South, I get this runtime:

runtime error: list index out of bounds
proc name: South (/obj/arrow/proc/South)
source file: arrow.dm,19
usr: Polantaris (/mob/player)
src: the arrow (/obj/arrow)
call stack:
the arrow (/obj/arrow): South()
Polantaris (/client): South()

I can't figure out how it's out of bounds, and I'm not in the condition(too tired to think) to really go through it throughly. If anyone can point out the problem please do so. Thanks.

Note: If I turn
var/list/menu[0][0]

into
var/list/menu[][]

I get a "Cannot read from list" runtime instead for the same line.
cursor_x is at 0 and list indices start at 1.
In response to tenkuu
I still get the error >__<
In response to Polantaris
Eh, I wasn't reading that closely the first time. :p

Make sure that menu is created first before you actually try to access anything in it. Declaring it as menu[0][0] does nothing since you aren't actually giving it any dimensions. You have a line for that in CommandText(...) but from the call stack you're trying to move the cursor before you create menu[][].

Also, the screen positions you're storing in the list basically fit a defined pattern so you really should be using a formula to calculate it.
In response to tenkuu
The arrow is created inside CommandText(...) so it would never even call the arrow's North or South unless it was there, and right after the arrow is created is when its given the dimensions.

I can't use a formula because theres several areas where the arrow will be, the same arrow. I need to make sure that it works correctly, and to do that, everytime it changes locations I either recreate the arrow, or its menu list.
In response to Polantaris
BUMP
In response to Polantaris
Polantaris wrote:
The arrow is created inside CommandText(...) so it would never even call the arrow's North or South unless it was there, and right after the arrow is created is when its given the dimensions.

Then I'm confused. MakeArrow() isn't called from inside CommandText() unless that happens after what you posted.
In any case, this code must be run before you can access anything in menu:

            P.arrows.menu = new/list(1,5)
P.arrows.menu[1][1] = "1,13"
P.arrows.menu[1][2] = "1,12:2"
P.arrows.menu[1][3] = "1,11:5"
P.arrows.menu[1][4] = "1,10:7"
P.arrows.menu[1][5] = "1,9:9"
In response to tenkuu
Yeah sorry, I noticed it after I posted, but that didn't fix the problem, instead I got it in the North or South. My friend Loduwijk then IMed me seeing the topic, we got it fixed. I meant to reply sooner, but I had to go to work. Thanks for the help though, you got me closer to the solution either way. Thanks!