Thread Tools Display Modes
06-23-09, 09:20 AM   #1
Frayol
A Deviate Faerie Dragon
 
Frayol's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 10
Swapping equipment sets in stealth

I've recently been trying out the Blizzard equipment manager with a view to no longer using Outfitter as it does far more than I need. So far been fairly satisfied, but about the only real automation I require is weapon swapping on my rogue. There are addons that will automate this, but nothing seems to work properly with most of the LDB equipment manager displays (i.e. they don't update with the weapon change) so I've taken a stab at my own version. This is what I've come up with:

Code:
local f = CreateFrame("FRAME", "Frame_fStealth");
f:RegisterEvent("UPDATE_STEALTH");

local function eventHandler(self, event, ...)
local nStance = GetShapeshiftForm();
	if nStance == 0 then EquipmentManager_EquipSet("Normal");
	elseif nStance ~= 0 then EquipmentManager_EquipSet("Stealth");
	else return;
end
end
f:SetScript("OnEvent", eventHandler);
It relies on two sets, one called "Normal" and one called "Stealth". On my rogue I have a full outfit for "Normal" and only a main hand dagger on "Stealth" with all other slots set to ignore. Everything seems to be working fine, but could some kind person please advise if I have missed anything or am doing something horrendously wrong?
  Reply With Quote
06-23-09, 10:40 AM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
"FRAME" should be "Frame"
  Reply With Quote
06-24-09, 05:13 AM   #3
Frayol
A Deviate Faerie Dragon
 
Frayol's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 10
Thanks, so I'm guessing that apart from that everything else was OK? In that case brilliant, I had a feeling that I was missing something or doing something wrong so it's good to know that it wasn't anything serious.
  Reply With Quote
06-24-09, 05:42 AM   #4
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
Originally Posted by Slakah View Post
"FRAME" should be "Frame"
That makes no difference whatsoever.

---

Your indentation is a bit weird, and the last else clause would never run (but everything should work without changes). It can be cleaned up and shortened a bit:
Code:
local f = CreateFrame("FRAME", "Frame_fStealth");
f:RegisterEvent("UPDATE_STEALTH");

local function eventHandler(self, event, ...)
	local nStance = GetShapeshiftForm();
	EquipmentManager_EquipSet(nStance == 0 and "Normal" or "Stealth");
end
f:SetScript("OnEvent", eventHandler);
__________________
... and you do get used to it, after a while.

Last edited by Foxlit : 06-24-09 at 05:55 AM.
  Reply With Quote
06-24-09, 07:34 AM   #5
Frayol
A Deviate Faerie Dragon
 
Frayol's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 10
Originally Posted by Foxlit View Post
Your indentation is a bit weird, and the last else clause would never run (but everything should work without changes). It can be cleaned up and shortened a bit:
Hmmm... not sure what happened with the indentation, it doesn't look like that on the actual file. As for the shortening, TYVM now that I see how you've put it I realise that I goofed a bit with that initially.
  Reply With Quote
06-24-09, 08:01 AM   #6
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Foxlit View Post
That makes no difference whatsoever.

---

Your indentation is a bit weird, and the last else clause would never run (but everything should work without changes). It can be cleaned up and shortened a bit:
Code:
local f = CreateFrame("FRAME", "Frame_fStealth");
f:RegisterEvent("UPDATE_STEALTH");

local function eventHandler(self, event, ...)
	local nStance = GetShapeshiftForm();
	EquipmentManager_EquipSet(nStance == 0 and "Normal" or "Stealth");
end
f:SetScript("OnEvent", eventHandler);
If you really want to clean it:
Code:
local f = CreateFrame('Frame')
f:RegisterEvent('UPDATE_STEALTH')
f:SetScript('OnEvent', function() EquipmentManager_EquipSet(GetShapeshiftForm() == 0 and 'Normal' or 'Stealth') end)
  Reply With Quote
06-25-09, 08:51 AM   #7
Frayol
A Deviate Faerie Dragon
 
Frayol's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2008
Posts: 10
Originally Posted by p3lim View Post
If you really want to clean it:
Code:
local f = CreateFrame('Frame')
f:RegisterEvent('UPDATE_STEALTH')
f:SetScript('OnEvent', function() EquipmentManager_EquipSet(GetShapeshiftForm() == 0 and 'Normal' or 'Stealth') end)
Now that is shortened! Tested it out and it all works perfectly, TYVM.

Is there any benefit to doing this way as opposed to how I was originally doing it other than shorter code?

Last edited by Frayol : 06-25-09 at 08:53 AM. Reason: corrected question
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Swapping equipment sets in stealth

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