ID:139875
 
Code:
mob
Move()
if(src.Moveing || src.Frozen) // If they are moving..
return // Stop
else
src.Moveing = 1 // Set there Moveing to 1.
..() // Calls the defualt of the Move() proc, which is to move of course :).
sleep(src.Move_Delay) // Sleeps the Move_Delay's set amount.
src.Moveing = 0


mob
npc // this is the NPC menus
Fire_Nation_Citizen
icon = 'npc.dmi'
icon_state = "npc_1"
New()
..()
wander(src)

mob
NPC // this is the NPC menus
Fire_Nation_Citizen
icon = 'npc.dmi'
icon_state = "npc_2"
New()
..()
wander(src)

mob
Npc // this is the NPC menus
Fire_Nation_Citizen
icon = 'npc.dmi'
icon_state = "npc_3"
New()
..()
wander(src)

Palace_Guard
icon = 'npc.dmi'
icon_state = "guard"

mob
proc
wander()
sleep(20)
step_rand(src)
src.wander()



mob
npc // this is the NPC menus
Water_Tribe_Citizen
icon = 'npc.dmi'
icon_state = "npc_1"
New()
..()
wander(src)

mob
NPC // this is the NPC menus
Water_Tribe_Citizen
icon = 'npc.dmi'
icon_state = "npc_2"
New()
..()
wander(src)

mob
Npc // this is the NPC menus
Water_Tribe_Citizen
icon = 'npc.dmi'
icon_state = "npc_3"
New()
..()
wander(src)

mob
npc // this is the NPC menus
Air_Nomad
icon = 'airnomadwhite.dmi'
icon_state = "npc_1"
New()
..()
wander(src)

mob
NPC // this is the NPC menus
Air_Nomad
icon = 'airnomadtan.dmi'
New()
..()
wander(src)

mob
Npc // this is the NPC menus
Air_Nomad
icon = 'airnomaddark.dmi'
New()
..()
wander(src)


Problem description:
runtime error: Maximum recursion level reached (perhaps there is an infinite loop)
To avoid this safety check, set world.loop_checks=0.
proc name: Move (/mob/Move)
Shutting down after encountering too many critical errors

You are getting this error because the maximum recursion level was reached.

Maybe if you actually posted the whole error, or relevant code (like, say, wander()) more help could be provided.
In response to Garthor
I had the wander() code in the previous post but here it is again.

mob
proc
wander()
sleep(20)
step_rand(src)
src.wander()
In response to Situs67
sleep() should go at the end to prevent runtime errors
If you must re-call a proc then spawn() it off
You can just use a while() loop for yours
The problem comes from wander() calling itself. When you call a proc, the calling proc waits for the called proc to finish and return its result. The caller goes on what's called the stack, and comes off again once the proc it called finishes. The stack is not infinite in size, so if a proc calls a proc that calls a proc that calls a proc, and so on forever, the stack will overflow.

Recursion is the term for when a function calls itself in this way, directly or indirectly.

The problem in wander() is that you're using recursion where you don't really need to be. A loop would be a better choice, or you can have the proc call itself with spawn(). Using spawn() creates a new "thread" instead of waiting for a response. (BYOND isn't really a multithreaded language, but spawn() basically simulates that.)

Lummox JR
In response to Lummox JR
Alright. So what should the new code look like. Just put "spawn()" where "wander()" is? Or just put sleep at the end?
In response to Falacy
Falacy wrote:
sleep() should go at the end to prevent runtime errors

What?

If you must re-call a proc then spawn() it off

The only situations in which you MUST "re-call" a proc is if you are deliberately using recursion... in which case using spawn() would break it.

You can just use a while() loop for yours

His and every other loop.
In response to Garthor
Garthor wrote:
What?

You can make the conditions of the while() what check for any null references. Then with a sleep at the end it will automatically kill itself instead of runtiming to death.

His and every other loop.

Yes, you could use a while() loop for any loop. You could also use a for loop, recursive calls, gotos, and others. Doesn't mean its always the best option.
In response to Situs67
mob/proc/wander()
while(src)
step_rand(src)
sleep(20)