ID:140911
 
Code:
1.
mob
proc
Wander()
if(istype(src.loc.loc, /obj/fuzetsu))
src.Wander()
return
else
step_rand(src)
src.Wander()

mob
human
icon='BFcharacterfordylan.dmi'
New()
src.Wander()

2.
mob
verb
Create(O as null|anything in typesof(/obj,/mob,/turf))
set category = "Staff"
set name = "Create"
set desc="Create a new mob, or obj"
if(!O)
return
new O(usr.loc)
usr << "You Create a(n) [O]"


Problem description:
Hi. I tried to make simple randomly wandering human that can't move when it's on /obj/fuzetsu, but when /obj/fuzetsu dissapears it can walk again. First code shows my human code and wandering proc. Second code shows my creating verb.
My problem is: when I launch the game and create /mob/human nothing happens. When I do that again dream seeker crashes and closes without any message. If I do it in dream daemon, it crashes after first time using create verb. (Note: I can create without a problem any other atom with Create verb)
What's wrong here?
Your Wander() proc is crashing Dream Seeker because it is instantly calling itself again endlessly, which will quickly overflow the stack (fill up memory) and crash. The first thing to do is not call Wander() from within Wander(), as that's called recursion and is not something you want here (though it does have valid uses). It causes each Wander() to wait for the next Wander() to finish, which never happens because it's waiting for the next one to finish. It crashes IMMEDIATELY because there's no sleep statement in there anywhere to slow it down. You should write a proc like that like so:

mob/proc/Wander()
//starts in a new thread
spawn()
//infinite loop
while(src)
step_rand(src)
//always have a sleep()
sleep(10)


Now, another issue is that the line if(istype(src.loc.loc, /obj/fuzetsu)) has nothing to do with standing "on" that object. For that, you would need to use locate(), like so:

if(locate(/obj) in src.loc)


Your Create verb has nothing to do with this.
In response to Garthor
Thank you so much. Works fine now.