Go to Page... |
|
Thread Tools | Display Modes |
08-30-09, 10:22 AM | #1 |
Some warlock buttons
I am at best a noob coder. I wrote these two buttons in lua. But, I access them through an xml because that was what I was learning.
The first button is a pretty simple warlock life drain button. If there is no target, it will show the current number of shards and the max number of shards to keep. If a 29th (my baf holds 28) is collected it is deleted. If soemone is targeted it shows the current health percentage in the soul stone circle until the percentage drops to 25% or below. Then it displays the drain soul spell icon. A click will cast drain soul at any time. the second button dispalys my pets current mana and health percentage. If health drops below 25% it reminds to health funle. If mana drops low it asks about life tap. One button controls both spells by accessing the left vs right mouse button. If this is helpful to anyone, here is what I wrote in the lua. But, I guess you would have to initialize the buttons in lua on your own. -- Customizable Stuff -- MAX SHARDS VARIABLE SET HERE. local maxShards = 28 -- Change the number above to increase or decrease number of shards -- MAX SHARDS VARIABLE SET END local ITEM_TO_DELETE = "Soul Shard"; local health = 0; local maxhealth = 0; local numShards = 0 -- **************************************************** -- * ON_LOAD COMMANDS * -- **************************************************** function ExecuteWarning_OnLoad() ExecuteWarning_BuffFrame:Show(); ExecuteWarning_BuffFrame:SetAttribute('type', 'spell') ExecuteWarning_BuffFrame:SetAttribute('spell', "Drain Soul") ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Gem_Amethyst_02") ExecuteWarning_Pet_BuffFrame:Show(); ExecuteWarning_Pet_BuffFrame:SetAttribute('type', 'spell') ExecuteWarning_Pet_BuffFrame:SetAttribute('spell1', "Health Funnel") ExecuteWarning_Pet_BuffFrame:SetAttribute('type2', 'spell') ExecuteWarning_Pet_BuffFrame:SetAttribute('spell2', 'Life Tap') ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_DemonicPact"); end -- **************************************************** -- * FUNCTIONS * -- **************************************************** -- * Add your own functions in the section below. I've also included several basic but -- * useful functions below to get you started. function round(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end function ExecuteWarning_Update(name, health, maxhealth) numShards = GetItemCount(ITEM_TO_DELETE); if numShards > maxShards then DeleteShard() end if (UnitName("target") == nil) then ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Gem_Amethyst_02") getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText( " "..numShards .."\n\n\n".. maxShards.." " ); end if (UnitIsDead("target") == 1) then ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Orb_04"); getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText( "Dead" ); else local name = UnitName("target"); local maxhealth = UnitHealthMax("target"); local health = UnitHealth("target"); local status = health.."/"..maxhealth; local percent = round( (health/maxhealth)*100); if (percent > 25) then ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\INV_Misc_Orb_04"); getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText(percent .. "%" ); elseif (percent <= 25) then getglobal(ExecuteWarning_BuffFrame:GetName().."_Text"):SetText(" "); ExecuteWarning_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_Haunting"); ExecuteWarning_Pet_BuffFrame:SetBackdropColor( 1, 0, 0, 1 ); end end if (UnitName("pet") == nil) then ExecuteWarning_Pet_BuffFrame:Hide(); else ExecuteWarning_Pet_BuffFrame:Show(); local name = UnitName("pet"); local maxhealth = UnitHealthMax("pet"); local health = UnitHealth("pet"); local status = health.."/"..maxhealth; local percent = round( (health/maxhealth)*100); local maxMana = UnitManaMax("pet"); local Mana = UnitMana("pet"); local status2 = Mana.."/"..maxMana; local percent2 = round( (Mana/maxMana)*100); if (percent > 25) then ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_DemonicPact"); getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( percent .."%\n\n\n".. percent2.."%" ); end if (percent2 <= 25) then ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_Metamorphosis"); getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( "LifeTap?\n\n\n(Right B)" ); end if (percent <= 25) then ExecuteWarning_Pet_BuffFrame:SetNormalTexture("Interface\\Icons\\Spell_Shadow_LifeDrain"); getglobal(ExecuteWarning_Pet_BuffFrame:GetName().."_Text"):SetText( "Funnel!\n\n\n(Left B)" ); end end end function DeleteShard() for i=0,4 do for j=1, GetContainerNumSlots(i) do local item = GetContainerItemLink(i,j) if item and item:find(ITEM_TO_DELETE) then PickupContainerItem(i,j) DeleteCursorItem() return end end end end |
|
WoWInterface » Featured Projects » nUI, MozzFullWorldMap and PartySpotter » Customization » nUI: Developer Chat » Some warlock buttons |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|