ID:179810
 
I'm having trouble with the music in my game.
I know how to put sounds in them but i have a problem.
Some easy stuff:

area
var
sound
Entered()
usr << sound(sound,1)
start1
sound = 'falala.mid'

Pretty simple i know..
ok next:

mob
Login()
usr.Move(locate(/area/start1))
..()

Now the problem comes when my "start1" area is a small
square. Each time i leave that square the music stops...

--------------
| | s | s = start1
| ----|
| |
| |
--------------

I tried making a huge "area" around the "start1" but when i leave the tiny square, the music replays itself.

Is there a way to associate any sounds with a map(.dmp)
instead of an area ?

Sorry 'bout my english.




I can think of a way, but it might be a bit complex.

Give each player a music variable.

Whenever you enter an area and tell it to play some music, play the music, and then set the music variable for the player to whatever the file name is.

for example:

usr << south('dungeon.mid',1)
usr.music = "dungeon.mid"

Then, whenever you enter an area to play music, check to see if the sound you want to play is equal to the player's music variable.

area/dungeon()
Entered(mob/M)
if(M.client)
if(usr.music == "dungeon.mid")
return
else
usr << sound('dungeon.mid',1)
usr.music = "dungeon.mid"


Cravens wrote:
area
var
sound
Entered()
usr << sound(sound,1)
start1
sound = 'falala.mid'

Now the problem comes when my "start1" area is a small
square. Each time i leave that square the music stops...

The sound cuts off because the sound for the default area is null. Whenever the player enters the default area, you tell it to play sound(null,1) which cuts all sound. As a side note, you do not want to use the usr variable in a proc. You'll get unpredictable results when the game goes multiplayer.

Here is a corrected Entered() proc for areas:
Entered(O) // O just entered the area.
if(sound) O << sound(sound,1)



I tried making a huge "area" around the "start1" but when i leave the tiny square, the music replays itself.

I'm not sure I understand what you're saying here. no matter what you do, there is an area around the start1 area. Every turf is in an area. If you don't specify which area, it will be in the world's default area.

If you move to another turf within start1, the Entered() proc for start1 shouldn't be called again. You can use Foomer's method to prevent replaying the same song when you move to different areas with the same sound.

Is there a way to associate any sounds with a map(.dmp)
instead of an area ?

Yes, but it's much simpler to do what you're trying to do with areas.
In response to Foomer
This code works fine if you remove the parentheses.

area/dungeon() // <------- remove ()
Entered(mob/M)
if(M.client)
if(usr.music == "dungeon.mid")
return
else
usr << sound('dungeon.mid',1)
usr.music = "dungeon.mid"


Do i need them or did you just misplace them?
In response to Cravens
I don't pay that much attention when I'm coding on the forums :oP, just remove them...