Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-29-23, 05:50 AM   #1
Yukka
A Theradrim Guardian
 
Yukka's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2020
Posts: 60
I need your help to combine two addons please [solved]

Hello, I tried to combine these two addons but it seems I cant get it right... Can someone create one addon with these two addons please?

First addon plays a sound when the pet dies and the second addon play a sound when the pet life is about 35%. If possible I prefer when the addon play the sounds from the addon folder just like in the second addon. Thanks.

First addon:

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterUnitEvent("UNIT_HEALTH", "pet")
  3. f:SetScript("OnEvent", function()
  4.   if not UnitExists("pet") or UnitHealth("pet") == 0 then
  5.     PlaySound(6595)
  6.   end
  7. end)

Second addon:

Lua Code:
  1. local _,PetHealthAlert=...
  2. local Frame=CreateFrame("ScrollingMessageFrame","!PHA",UIParent)   
  3. Frame.Threshold=35
  4. Frame.Warned=false
  5. -- Initialize
  6. function PetHealthAlert:Initialize()   
  7.     Frame:SetWidth(450)
  8.     Frame:SetHeight(200)
  9.     Frame:SetPoint("CENTER",UIParent,"CENTER",0,0) 
  10.     Frame:SetFont("Interface\\AddOns\\!PHA\\Res\\PHA_.TTF",30,"THICKOUTLINE")
  11.     Frame:SetShadowColor(0.00,0.00,0.00,0.75)
  12.     Frame:SetShadowOffset(3.00,-3.00)
  13.     Frame:SetJustifyH("CENTER")    
  14.     Frame:SetMaxLines(2)
  15.     --Frame:SetInsertMode("BOTTOM")
  16.     Frame:SetTimeVisible(2)
  17.     Frame:SetFadeDuration(1)       
  18.     HealthWatch:Update()
  19. end
  20. -- Update health warning
  21. function PetHealthAlert:Update()   
  22.     if(floor((UnitHealth("pet")/UnitHealthMax("pet"))*100)<=Frame.Threshold and Frame.Warned==false)then
  23.         PlaySoundFile("Interface\\AddOns\\!PHA\\Res\\PHA.ogg") 
  24.         Frame:AddMessage("- CRITICAL PET HEALTH -", 1, 0, 0, nil, 3)
  25.         Frame.Warned=true
  26.         return
  27.     end
  28.     if(floor((UnitHealth("pet")/UnitHealthMax("pet"))*100)>Frame.Threshold)then
  29.         Frame.Warned=false
  30.         return
  31.     end
  32. end
  33. -- Handle events
  34. function PetHealthAlert:OnEvent(Event,Arg1,...)
  35.     if(Event=="PLAYER_LOGIN")then
  36.         PetHealthAlert:Initialize()
  37.         return
  38.     end
  39.     if(Event=="UNIT_HEALTH" and Arg1=="pet")then
  40.         PetHealthAlert:Update()
  41.         return
  42.     end
  43. end
  44. Frame:SetScript("OnEvent",PetHealthAlert.OnEvent)
  45. Frame:RegisterEvent("PLAYER_LOGIN")
  46. Frame:RegisterEvent("UNIT_HEALTH")

Last edited by Yukka : 06-06-23 at 09:34 AM.
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Search/Requests » I need your help to combine two addons please


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