WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Macro Help (https://www.wowinterface.com/forums/forumdisplay.php?f=140)
-   -   Help please (https://www.wowinterface.com/forums/showthread.php?t=45181)

Farside 11-18-12 12:16 PM

Help please
 
I have this macro to toggle Auto-Loot on and off. It works fine except the Print message always says Off never On when I use the macro.


/run SetCVar("autoLootDefault",1-GetCVar("autoLootDefault")) print(("AutoLoot is %s"):format((GetCVar("autoLootDefault")==1) and "on" or "off"))

Phanx 11-18-12 01:36 PM

Code:

/run local v = GetCVarBool("autoLootDefault") SetCVar("autoLootDefault", v and 0 or 1) print(format("AutoLoot is now %s.", v and "off" or "on"))
The problem in your macro is that you're calling GetCVar immediately after SetCVar, at which point it's probably still returning the old value. My revised version will cache the current value, and use that for both the setting and the printing parts.

Farside 11-18-12 02:28 PM

Works perfectly! Thank you very much for helping me with this.

Farside 11-19-12 03:14 PM

I have another question, is there a way to have this print to MiksScrollingBattleText or maybe as a system message?

Seerah 11-19-12 03:34 PM

Change print to say UIErrorsFrame:AddMessage

Farside 11-19-12 04:09 PM

Thank you :banana:


All times are GMT -6. The time now is 10:01 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI