Thread Tools Display Modes
12-04-06, 09:34 PM   #1
Aznamir
A Fallenroot Satyr
 
Aznamir's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 26
2.0 Click casting - success/fail check, help!

So I have a button that inherits SecureActionButtonTemplate

I made 2 functions:

Code:
function PallyPower:ButtonPreClick(mousebutton)
  if (not InCombatLockdown()) then
    local classID = this:GetAttribute("classID");
    local spell = PallyPower:GetSpell(classID);
    local gspell = PallyPower_Greater .. spell;
    local unitid = PallyPower:GetUnitSmart(classID, mousebutton, spell);
    if not unitid then
        spell = nil;
        gspell = nil;
    end
    -- left click (do 15 minute buff)
    this:SetAttribute("type1", "spell");
    this:SetAttribute("unit1", unitid);
    this:SetAttribute("spell1", gspell);
    -- right click (do a 5 minute buff)
    this:SetAttribute("type2", "spell");
    this:SetAttribute("unit2", unitid);
    this:SetAttribute("spell2", spell);
  end
end

function PallyPower:ButtonPostClick(mousebutton)
  local classID = this:GetAttribute("classID");
  -- decisions, decisions...
  if (mousebutton == "LeftButton") then
    LastCast[classID] = 15 * 60;
  end
end
So on pre-click the mod find a nearby who is in range (according to IsSpellInRange() function) class member and assigns the spell attributes tot he button.

Problems:
1) If unitid or spell are nil (noone in range), the button does not do anything, and I need to catch the situation and not reset the timer. How to do it?

2) sometimes when people move out of range the click returns a red error message, but sometimes the cursor turns into a highligted hand, I guess expecting me to click on someone. How to prevent it?
I just don't want to cast anything if the result will be an obvious failure.

Could someone help?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » 2.0 Click casting - success/fail check, help!


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