Page 1 of 1

Volume Control Slider [Help]

Posted: 19 Oct 2008, 13:58
by Aus_Karlos
I can't seem to figure out how to create a Toggable GUI.
Ive fixed the TA Music widget but i want to add a slider for the volume level.
To be honest i don't even know where to start.
This is the code ive got to play a sound file with a set volume.

Code: Select all

Spring.PlaySoundStream("music/17.ogg",0.8)
but i want to change it to something like this.

Code: Select all

Spring.PlaySoundStream("music/17.ogg",Volvalue)
Could i have the input of the slider something like this..

Code: Select all

  Volvalue = {
    name   = 'Music Volume',
    desc   = 'Adjust the Volume level.',
    type   = 'number', min = 0, max = 1, step = 0.05,
    value  = 0.8
  }=
See i dont even know how to add the mouse control or how the slider will interact with the code above.

So i desperately need some help.

Thanks

Re: Volume Control Slider [Help]

Posted: 19 Oct 2008, 14:54
by BrainDamage
create a local variable which stores playback volume, attach a command handler to set such variable, such as
/luaui musicvolume 0.8
then make a copy of the volume bar widget, and change the source so instead of changing spring game volume it sends the aforementioned command passing the silder % value

Re: Volume Control Slider [Help]

Posted: 19 Oct 2008, 15:40
by Aus_Karlos
I can't find the volume bar widget anywhere. I havn't got it nor can i find it on the web to download it.

Re: Volume Control Slider [Help]

Posted: 19 Oct 2008, 16:19
by very_bad_soldier

Re: Volume Control Slider [Help]

Posted: 20 Oct 2008, 17:04
by MelTraX
Or use viewtopic.php?f=23&t=15280 .. You can pretty much use what you posted in the first post and add a options = { ... } around it and you're done.. I'd really like to know why noone seems to like it..

Re: Volume Control Slider [Help]

Posted: 22 Oct 2008, 11:45
by DarkOppressor
Does the current TA Music widget not work at all with .77b5? I just tried it out, and no music is playing. If this is the case, I assume you are fixing it for this obvious reason, in which case I can't wait for you to finish :-D

Re: Volume Control Slider [Help]

Posted: 24 Oct 2008, 07:09
by DarkOppressor
Huh. You know, I looked at the LUA file for the TA Music widget, and changed every instance of Spring.PlaySoundStream(blah blah blah) from 0.5 to 0.7, and the widget now seems to be working. I have TA music again! :-)