Jump to content

Starting an Add-on Part 2: Scripts


valros

Recommended Posts

ok guys well i have had Starting an Add-on Part 1 up for sometime now it time to see who did thier homework. this is a quick script i typed up to do the following.

 

checks to see if you are missing more then <MissingHP>

checks to see if you do not currently have renew

then casts Renew with the rank of <Rank> on yourself

otherwise it does nothing

 

this is the script. you need to open the FPmod.lua file with notepad and paste the following and save.


function RenewMe(MissingHP, Rank)



if UnitHealthMax('player') - UnitHealth('player') > MissingHP then

 if Get_Player_Buff_Index('Renew') == -1 then

 	CastSpellByName('Renew(Rank '..Rank..')', true);

 end

end



end



function Get_Player_Buff_Index(BuffName)



local pbuff_id = 0

local pbuff_name = ''

local pbuff_index, untilCancelled = GetPlayerBuff(pbuff_id, "HELPFUL")



while pbuff_index >= 0 do



 FPmodTooltipTextLeft1:SetText(nil);

 FPmodTooltip:SetPlayerBuff(pbuff_index);



 pbuff_name = FPmodTooltipTextLeft1:GetText();



 if pbuff_name == BuffName then

 	break;

 end



 pbuff_id = pbuff_id + 1;

 pbuff_index, untilCancelled = GetPlayerBuff(pbuff_id, "HELPFUL");

 

 if pbuff_id > 20 then 

 	pbuff_index = -1;

 	break;

 end

end



return pbuff_index;

end

 

to run this script make a macro with the following


/script RenewMe(<MissingHP>, <Rank>);

/cast <some spell>

 

<some spell> could be the heal you use the most so you don't have to worry about your health as much when healing tanks that are missing more health.

 

let me know if you have any questions

Share this post


Link to post
Share on other sites

code windows do that on their own. i started useing those so when you copy and paste it would save the tabs and make the code more readable.

Share this post


Link to post
Share on other sites

×
×
  • Create New...
[[Template core/front/_liskoduje/liskodujeJS is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]