|
Well, first off, you can't automatically do anything with an addon. That kind of functionality was blocked waaaaay back with patch 1.10, long before even Burning Crusade. You must have some user input, whether it is a key or keys being pushed or a mouse button clicked. However, you can get an addon to fire a macro. That's a bit complex to write here, so again, I will point you to the book I mentioned, which teaches you pretty much everything you need to know.
That said, in order to detect if you are in combat, you would want
Code: function MyAddon:CheckingForCombat()
self:RegisterEvent("PLAYER_REGEN_ENABLED") -- normal engergy gains like Mana and especially Health only occur outside of combat
self:RegisterEvent("PLAYER_REGEN_DISABLED") -- Health regen is disabled during combat. best way to check for combat, really
if event == "PLAYER_REGEN_DISABLED" then
-- do stuff while in combat
else
--- do stuff out of combat
end
end
[edited by: myrroddin at 10:00 PM (GMT -6) on 29 Jun 2009]
Project Lead for SmartRes and MrBigglesworthDeath. SmartRes2 coming soon!
|