ID:2055120
 
Problem description:
hey as you can see i have a snippet of my code here. i am receiving run-time errors and a error on the switch() for the axis choosing.
player
verb
throwKunai()
var/obj/Kunai/Q = new ()
Q.Owner = usr
obj/Kunai
icon = 'Kunai.dmi'
var
player/Owner
New()
usr.loc = Owner.loc
Move()
walk(usr, Owner.dir, 1)

proc
objClash(atom/movable/a, distance)
objFlip(atom/movable/a, times2flip, degrees)
objFly(atom/movable/a, distance)

Bump(atom/movable/a, player/M)
if(istype(M, /player)) if(src.Owner == M)
return objClash(src, 1)

if(istype(a, /obj/Kunai)) objClash(src, 1) ; objClash(a, 1)

objClash(atom/movable/a, distance)
..()
for(a in obounds(src, distance))
objFlip(a, 20, 20)

objFlip(atom/movable/a, times2flip, degrees = 20)
..()
objFly(a, 10)
var/icon/Q = new(a.icon)
animate(transform = Q.Turn(matrix(),degrees,times = 5))
a.icon = Q

objFly(atom/movable/a, distance, axis)
..()
var
vy_x = pixel_x
vy_y = pixel_y
vy_z = pixel_z

max_x = 10
max_y = 10
max_z = 10

spawn()
while(a)
sleep(0.3)
//switch(axis)
if(axis == vy_x)
step_x = vy_x
if(vy_x >= max_x - 1)
vy_x --
else
vy_x ++

else if(axis == vy_y)
step_y = vy_y
if(vy_y >= max_y - 1)
vy_y --
else
vy_y ++

else if(axis == vy_z)
if(vy_z >= max_z - 1)
vy_z --
else
vy_z ++
axis = pick(vy_x, vy_y, vy_z) //chooses the axis.


Error
runtime error: Cannot read null.loc
proc name: New (/obj/Kunai/New)
source file: kunai.dm,54
usr: Hebrons (/player)
src: Kunai (/obj/Kunai)
usr.loc: the grass (1,1,1) (/turf/grass)
src.loc: null
call stack:
Kunai (/obj/Kunai): New()
Hebrons (/player): throwKunai()