ID:176007
 
I'm trying to build conveyor belts for my game and this is what I've got so far:

obj
Move_Pad
New()
spawn while(1)
sleep(10)
cycle()
..()
proc/cycle()
for(var/obj/i in loc.contents)
move(i)
cycle()
proc/move()
icon = 'Mover.dmi'
EAST
move(obj/i as obj)
i.Move(x-1,y,z)
icon_state = "EW"


Unfortuantly, when it runs I get this runtime
runtime error: Cannot execute null.Enter().
proc name: move (/obj/Move_Pad/EAST/move)
source file: TitanNetRPG.dm,845
again and again until it stops running the proc to prevent overload.

Some debugging help please?
Sorry can't help ya, But I wonder what would happen if it DID overload. Would your computer blow up or somethin'? :D

~ Jermman
In response to Jermman
Nothing. The computer would just crash.
In response to Hazman
AAwwwwwwww
...
EAST
move(obj/i as obj)
i.Move(x-1,y,z)


Move() for movable atoms takes a new location as the first argument, and you passed in each separate coordinate. Try: i.Move(locate(x-1,y,z)).

Another thing I want to draw your attention to is the way you start cycle(). You have a loop that keeps calling cycle, then later on you keep calling cycle recursively without spawning it off! That's going to become a big mess later on. A much better way to handle this would to change some things. In New() start cycle off, then you're free to keep calling recursively, making sure you spawn() it off to prevent overflowing the call stack.

New()
spawn(1)cycle()
..()
proc/cycle()
for(var/obj/i in loc.contents)
move(i)
spawn()cycle()
In response to tenkuu
OK. After a bit of tweaking and pulling, I ended up with
    Move_Pad
New()
spawn while(1)
sleep(10)
cycle()
..()
proc/cycle()
for(var/obj/i in loc.contents)
if(i != src)//uhhh.... marked.
move(i)
proc/move()
icon = 'Mover.dmi'
EAST
move(obj/i as obj)
i.Move(locate(x-1,y,z))
icon_state = "EW"
Which works. Actually, if you remove the marked line, it's quite funny watching a conveyor belt 'swim' accross the map. Thanks for your help.