Quantcast
Help with Hunter pet addon (WoW classic) - WoWInterface
Thread Tools Display Modes
10-15-20, 03:12 PM   #1
awildgoose11
A Defias Bandit
Join Date: Mar 2020
Posts: 3
Question Help with Hunter pet addon (WoW classic)

I am a complete noob with Lua, but the basic thing I want it to do is use the message to pop up on the screen when the "var1" from GetPetHappiness() goes from 3 to 2.

Any help would be appreciated!

Code:
local p = {}
local var1,var2,var3=GetPetHappiness()
function p.repeatloop()
    local var1,var2,var3=GetPetHappiness()
    local result
 
    result = ';repeat\n'
    repeat 
        result = result .. ":var1 = " .. var1 .. '\n'
        var1,var2,var3=GetPetHappiness()
    until var1 = 2
    message('Feed your pet!')
 
    return result
end

return p
  Reply With Quote
10-15-20, 05:14 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,292
The basics would be something like:
Lua Code:
  1. local maxNotifications = 3
  2. local f = CreateFrame("Frame")
  3. f:RegisterEvent("UNIT_HAPPINESS")
  4. f.happiness = 0
  5. f.happinessCount = 0
  6. f:SetScript("OnEvent", function(self, event, ...)
  7.     local unit = ...
  8.         if unit ~= "pet" then return
  9.     end
  10.     local happiness, damagePercentage, loyaltyRate = GetPetHappiness()
  11.     if self.happinessCount > maxNotifications and self.happiness == happiness then
  12.         return
  13.     end
  14.     if happiness ~= self.happiness then
  15.         self.happinessCount = 0
  16.     end
  17.     self.happinessCount = self.happinessCount + 1
  18.     self.happiness = happiness
  19.     if happiness == 1 then
  20.         UIErrorsFrame:AddMessage("FEED YOUR PET ALREADY!!!", 1.0, 0, 0, 1.0)
  21.     elseif happiness == 2 then
  22.         UIErrorsFrame:AddMessage("Your pet is a little miffed with you!", 1.0, 1.0, 0, 1.0)
  23.     end
  24. end)
UNIT_HAPPINESS is a rolling event so as is, this only shows a message 3 times when the happiness level changes.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Help with Hunter pet addon (WoW classic)

Thread Tools
Display Modes

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