ID:165040
 
Areas are evil to me. I just don't get the Enter() and Exit() . If you don't call the parent in those procs, are you not allowed to get in/out? Well, anyway, I need to know two things.
First, this is my wander() proc.
mob/proc/Wander(D)
for()
step(src,pick(NORTH,SOUTH,EAST,WEST,0,0,0))
sleep(D)

how would I make it so that the mob can't Wander out of a certain area, like for example che chef can't wander out of the kitchen?
And second, How would I make it so that a certain MIDI plays in each area?

I'm sure these are really nooby questions, like every time, but if someone could at least help me learn about areas that would be great. Thanks.
Basically, whenever you try to enter/exit an area, the enter proc is called. If you return 1, then they can enter. If you return 0, they can't. You don't have to call the parent. So to block a Chef from leaving the kitchen:
area/kitchen/Exit(O)
if(istype(O, /mob/Chef)) return 0
else return 1


And if you wanted to play a sound for the area, I'm not sure which method would better, defining a variable for all areas that would have the midi in it, or just having an Enter proc for each area that you want music to play in...but I'd choose the first:
area/var/areaMusic = 'whatever.mid'

area/Enter(O)
if(areaMusic) O << areaMusic
return ..()
In response to Ephemerality
But it's important to call the parent, or else you'll have problems. For example, say I did this to prevent people entering a turf unless they have a particular item in them:

turf/special/Enter(mob/m)
if(ismob(m))
if(locate(/obj/key) in m) return 1 //BAD!
else return 0
.=..()


Then, any mob who has the item can /always/ enter the turf, no matter what. If the turf is dense, they can enter. If there's someone already in the turf, they can enter. That's probably not what you want.
In response to Ephemerality
(Sorry for the sudden bump, i've been away)
Well, the "return 0" and "return 1" for Enter/Exit procs is all i needed to know for the first one, but i'm not so sure about the area tunes. But i'll give it a go.
Well, here's what i wrote:
area
var/areaMusic
Enter(O)
O<<sound(areaMusic,1)
return ..()
kitchen
areaMusic='kitchen.mid'
Exit(O)
if(istype(O,/mob/chef)) return 0
else return 1
field
areaMusic='field.mid'

But no music! The chef thing in the kitchen works though, but what's up with the music??
In response to Jp
Yes, but thats important for turfs, not areas, or anything else for that matter.
In response to Kaioken
Umm... what isn't? I just want to know how to make the sounds work.
In response to Adam753
You would have figured what I referred to out if you checked what post I replied to. ;O
In response to Kaioken
Oh, right, Jp's turf/Enter() thing. Sorry i'm not thinking straight, i've been making a sell() verb for my friend and a stacking items inventory for myself AND trying to work on high level algebra in maths class, if I see one more line graph my head is going to explode!
Well, actually i've solved the problem now, I'm not sure if my computer or BYOND is responsible for this but i'm using .mid's which don't seem to work now, so i'll just go convert them to .wav's and problem solved! Thanks.