Thread Tools Display Modes
11-18-12, 12:16 PM   #1
Farside
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
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"))
  Reply With Quote
11-18-12, 01:36 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-18-12, 02:28 PM   #3
Farside
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Works perfectly! Thank you very much for helping me with this.
  Reply With Quote
11-19-12, 03:14 PM   #4
Farside
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
I have another question, is there a way to have this print to MiksScrollingBattleText or maybe as a system message?
  Reply With Quote
11-19-12, 03:34 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Change print to say UIErrorsFrame:AddMessage
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-19-12, 04:09 PM   #6
Farside
A Deviate Faerie Dragon
Join Date: Aug 2009
Posts: 19
Thank you
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » Help please

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off