Reply
 
Thread Tools Display Modes
Old 11-18-12, 11:16 AM   #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"))
Farside is offline   Reply With Quote
Old 11-18-12, 12:36 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 3,703
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.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Old 11-18-12, 01: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.
Farside is offline   Reply With Quote
Old 11-19-12, 02: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?
Farside is offline   Reply With Quote
Old 11-19-12, 02:34 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 9,479
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

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

Go BackWoWInterface » 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