ID:146838
 
I'm having some problems with sound area entering on multiple sounds off an exit.
What I'm trying to do is like this.

Note: It is for a Pokémon game, I Know it bay be a lil odd *There are a lot already on here. but i'm making an exact copy of Ruby and Saphire

When a person enters from the south entrance *LittleRoot* it plays the "PkmRS_101102103.mid" then when they get to the exit of the *Route 101* it plays the "Oldale.mid" as they enter *Oldale Town*.
then
If the person Enters from the north from *Oldale Town* it plays the "PkmRS_101102103.mid" as they are going through *Route 101* and then they Exit from the south at *LittleRoot* it plays the "LittleRootTown.mid".

I hope that kinda sums it up, lol.

here is a small ASCII Diagram to give a visual.
 
------------
|      & amp;nbsp;     & amp;nbsp;   |
|    Oldale & nbsp;  |
|      & amp;nbsp;     & amp;nbsp;   |
----      ----
     |       |
----      ----
|      & amp;nbsp;     & amp;nbsp;   |
|  Route101  |
|      & amp;nbsp;     & amp;nbsp;   |
----      ----
     |       |
----      ----
|      & amp;nbsp;     & amp;nbsp;   |
|  LittleRoot |
|      & amp;nbsp;     & amp;nbsp;   |
------------

Here is the code I'm having a problem with.

Note: I might have it completly wrong because when ever I exit, I always get the "LittleRootTown.mid".

area/musictiles
littleroot_to_oldale
name=""
Entered()
usr<<sound('PkmRS_101102103.mid',1)
Exited()
if(dir==NORTH)
usr<<sound('PkmRS_Oldale.mid',1)
if(dir==SOUTH)
usr<<sound('LittleRootTown.mid',1)
No put usr in proc. Ungh.

Lummox JR
Couple of problems.

1) DO NOT USE USR IN ENTER, ENTERED, OR EXITED (or most procs, for the matter). It will not behave as you expect.

2) Entered() is called by the atom, here an area. What you want is the passed value of Entered(atom/movable/Obj). Obj is the atom that entered. Send it the sound.

3)Same goes for Exited(atom/movable/Obj). Obj is the /obj or /mob that is leaving. Check its dir (I recomend using a switch()). Currently, you are implicitly checking the src.dir, in other words the dir of area/musictiles.

Just a reminder that F1 pulls up a wonderful help menu that explains the format of BYOND's functions.
In response to Lummox JR
Sorry Lummox JR and Jmurph, I forgot it was a proc >.< *A dumb error on my part*.

Jmurph, I don't uderstand what u mean by the switch() and the atom/movable/Obj. see i still don't completly understand everything in DM. As for the Help F1 thing, i wouldn't Know where to even look.

Edit: Basicly all i'm needing help in how to make it, if u leave from the north section of the area, it plays "PkmRS_Oldale.mid" and if u leave from the south exit, it plays "LittleRootTown.mid", to put it simpaly.
In response to ElderKain
Ok, first things first. In DM, if you hit F1, the help window comes up. If you have mouse-highlighted a DM function, it will look that up. Otherwise, you can search by topic. This is a *fantastic* feature as it explains *every* procedure and feature of BYOND.

To make it play a given sound, all you would need is something like:
<code> area music Exited(mob/M) switch(M.dir) if(NORTH) M << 'music1.mid' if(SOUTH) M << 'music2.mid' <code> What is happening is that whenever a mob (M) exits an area/music, it will play a certain sound if they are facing north and another if south.
In response to Jmurph
Jmurph, please use <dm> and </dm> tags when posting some DM, it makes it much easier to read. Thank you.

-Ryan
In response to Jmurph
lol, thx for your guys help anyways
I decided to take the bulky ways out, i just have each section in an area, with only the Entered() proc.
so like when u wnter Littleroot it plays its song, and the same for rout101 and Oldale. Its a lil cluttery, but it works just fine. thanks for your guys' help anyways.
Exited()
if(dir==NORTH)
usr<<sound('PkmRS_Oldale.mid',1)
if(dir==SOUTH)
usr<<sound('LittleRootTown.mid',1)


That checks the direction the area is pointing in. You would want to check the direction the player is heading in like this:

Exited(var/atom/a)
var/mob/m
if(ismob(a))
m=a
if(m.dir==NORTH)
m<<sound('PkmRS_Oldale.mid',1)
if(m.dir==SOUTH)
m<<sound('LittleRootTown.mid',1)


And remember, usr unfriendly.
In response to Lummox JR
lol lummox like 5/10 help posts i put in when i first started coding you sed something like that to
In response to Dragon-wars
Maybe because you shouldn't use usr in a proc?
In response to Jp
Jp wrote:
That checks the direction the area is pointing in. You would want to check the direction the player is heading in like this:

> Exited(var/atom/a)
> var/mob/m
> if(ismob(a))
> m=a
> if(m.dir==NORTH)
> m<<sound('PkmRS_Oldale.mid',1)
> if(m.dir==SOUTH)
> m<<sound('LittleRootTown.mid',1)
>

And remember, usr unfriendly.

You aren't wrong, but it would alot less messy to do this:

Exited(mob/M)
if(istype(M))
if(M.dir==NORTH)
M << sound('PkmRS_Oldale.mid',1)
if(M.dir==SOUTH)
M << sound('LittleRootTown.mid',1)
In response to Wizkidd0123
Point.