WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Macro Help (http://www.wowinterface.com/forums/forumdisplay.php?f=140)
-   -   [Request] Macro to toggle sound (http://www.wowinterface.com/forums/showthread.php?t=40664)

litesung 06-29-11 09:39 PM

[Request] Macro to toggle sound
 
Does anyone know of a macro that will toggle sound on and off?
I want to use bindpad to bind it to a key, so that if I want to mute WoW I can just press that key, and press it again to unmute wow.

Nibelheim 06-29-11 10:27 PM

Quote:

Originally Posted by litesung (Post 240383)
Does anyone know of a macro that will toggle sound on and off?
I want to use bindpad to bind it to a key, so that if I want to mute WoW I can just press that key, and press it again to unmute wow.

Off:

/run SetCVar("Sound_EnableSFX", 0)


On:

/run SetCVar("Sound_EnableSFX", 1)

Seerah 06-29-11 10:43 PM

To make it into a toggle...
Quote:

/run SetCVar("Sound_EnableSFX",GetCVar("Sound_EnableSFX")==0 and 1 or 0)

Nibelheim 06-29-11 11:17 PM

Oops, my bad.

Quote:

Originally Posted by Seerah (Post 240386)
To make it into a toggle...

That's the ticket :)

litesung 06-30-11 06:51 PM

Nibelheim always pulls through for me :p ty once again! TY to you too seerah!

This toggles the Sound Effects only though, so i just have to modify it to toggle sound only.

/run SetCVar("Sound_EnableAllSound",GetCVar("Sound_EnableAllSound")==0 and 1 or 0)

This is the new macro I'm using, but the problem is it only toggles sound off if it's on, and doesn't turn it back on if pressed. (stays muted)

SDPhantom 06-30-11 08:31 PM

That's because the old GetCVar() function either returns a string or nil. There are Lua functions provided in the default UI that are run by the keybind system for toggling music and sound. Using the default keybindings, you can use Ctrl+M and Ctrl+S for music and sound respectively. To do this in a macro, you make calls to Sound_ToggleMusic() and/or Sound_ToggleSound(). Both are defined in Sound.lua within the FrameXML.

Toggle Music:
Code:

/run Sound_ToggleMusic();
Toggle Sound:
Code:

/run Sound_ToggleSound();

Ketho 07-01-11 11:22 AM

Quote:

Originally Posted by SDPhantom (Post 240478)
That's because the old GetCVar() function either returns a string or nil.

Why did blizzard change the old functionality?
I think the old functionality was much more useful :(

litesung 07-01-11 02:53 PM

So there's no way to turn it into a toggle? It has to be done with two different macros?

Nibelheim 07-01-11 03:45 PM

This should work:

Code:

/run local c = "Sound_EnableAllSound"; local s = GetCVar(c) or "0"; if s == "1" then SetCVar(c, "0") else SetCVar(c, "1") end

SDPhantom 07-01-11 06:59 PM

Quote:

Originally Posted by Ketho (Post 240547)
Why did blizzard change the old functionality?
I think the old functionality was much more useful :(

GetCVar() has always acted this way. Blizzard later created GetCVarBool() that returns CVars stored as "0" and "1" as a boolean.





Quote:

Originally Posted by litesung (Post 240565)
So there's no way to turn it into a toggle? It has to be done with two different macros?

See my post above:
Quote:

Originally Posted by SDPhantom (Post 240478)
There are Lua functions provided in the default UI that are run by the keybind system for toggling music and sound... To do this in a macro, you make calls to Sound_ToggleMusic() and/or Sound_ToggleSound(). Both are defined in Sound.lua within the FrameXML.

Toggle Music:
Code:

/run Sound_ToggleMusic();
Toggle Sound:
Code:

/run Sound_ToggleSound();

Note: These are two different commands, you can put them together in a single macro if you wish.
Code:

/run Sound_ToggleMusic();
/run Sound_ToggleSound();

or more efficiently...
Code:

/run Sound_ToggleMusic();Sound_ToggleSound();

Ketho 07-02-11 08:30 AM

Quote:

Originally Posted by SDPhantom (Post 240581)
GetCVar() has always acted this way. Blizzard later created GetCVarBool() that returns CVars stored as "0" and "1" as a boolean.

If I remember correctly, GetCVar used to return "0" instead of just a nil, breaking the following example ..
Code:

/run SetCVar("Sound_EnableSFX", 1-GetCVar("Sound_EnableSFX"))
I can remember that the above example script used to work, but not anymore now :(

litesung 07-02-11 08:36 AM

Quote:

Originally Posted by Nibelheim (Post 240568)
This should work:

Code:

/run local c = "Sound_EnableAllSound"; local s = GetCVar(c) or "0"; if s == "1" then SetCVar(c, "0") else SetCVar(c, "1") end

Quote:

Originally Posted by SDPhantom (Post 240581)
or more efficiently...
Code:

/run Sound_ToggleMusic();Sound_ToggleSound();

These two work perfectly :)

I tried them both, Nib's is silent (no notification), and Phantom's notifies you "Sound Effects Enabled/Disabled" message.

THANK YOU EVERYONE! Hopefully no future patches break these.


All times are GMT -6. The time now is 04:00 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC