ID:156562
 
How do I make a verb so people can hear music in different volumes (An "Edit Volume" verb so whatever song plays at any time in the game plays at a higher or lower volume than normal?) like in Teridal (with the scroll bar that edits volume in percentages)?
Try something like this:

mob
var
music_volume = 100
sound/current_music = null

verb
Change_Music_Volume(N as num)
music_volume = N

if (current_music != null)
current_music.volume = music_volume

proc
Play_Music(F as sound)
var/sound/S = new F // make a new copy of the file to play
S.volume = music_volume // set the volume to the player's preferred
current_music = S // change the player's current music variable
src << S // play the music to the user (any previous music
// will be deleted since this new music is overwritten)
In response to Makeii
Makeii wrote:
Try something like this:

> mob
> var
> music_volume = 100
> sound/current_music = null
>
> verb
> Change_Music_Volume(N as num)
> music_volume = N
>
> if (current_music != null)
> current_music.volume = music_volume
>
> proc
> Play_Music(F as sound)
> var/sound/S = new F // make a new copy of the file to play
> S.volume = music_volume // set the volume to the player's preferred
> current_music = S // change the player's current music variable
> src << S // play the music to the user (any previous music
> // will be deleted since this new music is overwritten)
>

Ill try this later, im currently playing mafia and if I have any problems ill post here.
In response to Narutorox123456
Narutorox123456 wrote:
Makeii wrote:
Try something like this:

> > mob
> > var
> > music_volume = 100
> > sound/current_music = null
> >
> > verb
> > Change_Music_Volume(N as num)
> > music_volume = N
> >
> > if (current_music != null)
> > current_music.volume = music_volume
> >
> > proc
> > Play_Music(F as sound)
> > var/sound/S = new F // make a new copy of the file to play
> > S.volume = music_volume // set the volume to the player's preferred
> > current_music = S // change the player's current music variable
> > src << S // play the music to the user (any previous music
> > // will be deleted since this new music is overwritten)
> >

Ill try this later, im currently playing mafia and if I have any problems ill post here.

It doesn't work for me because I get runtime errors, but I changed my mind about using this feature in my game. Sorry for bothering you about it.
In response to Narutorox123456
Well, in case you decide otherwise:

Look up the arguments in the sound proc.
src << sound(file,repeat=0,wait,channel,volume)

for the volume you set it as a number. You can also update sounds/music currently playing, let me know if you need help with that.