ID:2180243
 
So I've added music to my game, and I'm tryin to do a volume control. For clarity purposes, this is what I'm trying to do:

https://gyazo.com/a08053bfebd6663d6f73acd7fd871a8d

I want the music volume to go up or down as you drag the bar. I know in the interface there's a section labeled "Command to run when value has changed". But I'm not sure how to go about coding the command to do what I'm trying to do. I don't want the sound file that's already playing to restart if possible. In other words, I need the value of the adjustable bar to correspond with music_volume

The variables I have are:
music_volume --- controls the volume of sounds
music --- the sound file playing to the player

You can update the volume of a sound without restarting it by applying the SOUND_UPDATE flag to its status variable:
client
var tmp
sound/music // The music currently playing

proc
// e.g. client.PlayMusic(sound('music.ogg'))
PlayMusic(sound/Music)
music = Music
Music.status |= SOUND_STREAM
src << Music

SetMusicVolume(Volume)
music.volume = Volume
music.status |= SOUND_UPDATE
src << music

// You can also mute a sound while it still plays
// with status SOUND_MUTE
// or pause with status SOUND_PAUSE
// (sending the sound again with just SOUND_UPDATE unpauses/unmutes)

verb
// The command to run when changed should be (without quotes):
// "volume-slider [[*]]"
volume_slider(Volume as num)
set hidden = TRUE
SetMusicVolume(Volume)
Thank you, friend. Works perfectly