mob/Login()
usr.action = "login"
usr.loc = locate(1,1,1)
world/New()
..()
spawn() region_info()
proc/region_info(M as mob in /area/region/hondoria)
if(usr.loc == locate(/area))
M << "blah!"
if(usr.loc == locate(/area/region/hondoria))
spawn while(1) // infinite loop
sleep rand(40,60)
M << "Region Report: Hondora"
As soon as I login I get this runtime error:
proc name: region info (/proc/region_info)
source file: initialization.dm,30
usr: null
src: null
call stack:
region info(null)
: New()
2. Instead, you would define the argument to region as "mob/M". That means you won't get compiler errors when you try to do things like M.loc.
3. Don't use usr in procs. In this case, use M.loc instead. The reason you would have got compiler errors when you tried M.loc before was because you hadn't defined it as in #2. The actual problem wasn't the M.loc bit, it was the definition of M that was wrong.
4. You're trying to do a region report for a single mob in region_info(), but you're calling it as if you want it to do the report for all mobs. Either method works, but you need to be consistent. =)
5. As your proc stands, even if it was correct it wouldn't work as you want it to. It would check M's location WHEN THE PROC WAS CALLED, and forevermore send M region reports for that region, rather than the region they're actually in at the time.
6. I'd recommend a different system anyway. There's a handy feature in BYOND that is useful here: If you send a text message to an atom, everything in the atom's contents (and its' contents' contents, and so on) gets the text message as well. So you can actually just send the message to the area, and it will automatically display it to everyone in that area. Spiffy, huh? =)
That also means you can get away with having just one loop. Which means less CPU usage, which is a Good Thing(tm). We can optimise it even further, though, by avoiding looping through the whole world to find our areas. We can use a list to keep track of the areas instead, like this:
Then the rest of the region info system can be simple, elegant, and ultra-optimised! It even slices and dices! (I made that last part up.)
I took the liberty of increasing the amount to sleep for. The sleep amount is in 1/10 seconds, so 40 actually means 4 seconds, and I'm guessing a report every 4-6 seconds would be annoying. =) You can of course change the delay to whatever you want.
Phew! What an essay. Hope that helped.