Volume Control Slider [Help]

Volume Control Slider [Help]

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
Aus_Karlos
Posts: 2
Joined: 19 Oct 2008, 13:47

Volume Control Slider [Help]

Post 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
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

Re: Volume Control Slider [Help]

Post 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
Aus_Karlos
Posts: 2
Joined: 19 Oct 2008, 13:47

Re: Volume Control Slider [Help]

Post 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.
MelTraX
Posts: 470
Joined: 02 Jan 2007, 16:18

Re: Volume Control Slider [Help]

Post 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..
User avatar
DarkOppressor
Posts: 59
Joined: 14 Mar 2006, 07:53

Re: Volume Control Slider [Help]

Post 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
User avatar
DarkOppressor
Posts: 59
Joined: 14 Mar 2006, 07:53

Re: Volume Control Slider [Help]

Post 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! :-)
Post Reply

Return to “Lua Scripts”