Thread Tools Display Modes
04/25/24, 03:15 AM   #1
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,001
Yes, having a timer run every 15s as in your case is fine.
Just make sure the timer unregisters properly once your bounty is gone, and does not register with a new name (reuse the same name so it "overwrites" old exisitng ones!) once next bounty comes up.
  Reply With Quote
04/25/24, 03:14 PM   #2
Vilkasmanga
AddOn Author - Click to view addons
Join Date: Dec 2023
Posts: 7
Originally Posted by Baertram View Post
Yes, having a timer run every 15s as in your case is fine.
Just make sure the timer unregisters properly once your bounty is gone, and does not register with a new name (reuse the same name so it "overwrites" old exisitng ones!) once next bounty comes up.
Great, thanks. I think I coded this correctly (thanks to your and others' help, ofc)

Code:
function FarmersToolkit.BountyCheck()

        local CurBounty=GetFullBountyPayoffAmount();
        local identifier="FarmersToolkit-BountyCheck";

        -- In case this is the first time we've been called this session...
        if ( type(FarmersToolkit.BountyValue) == "nil" ) then
                FarmersToolkit.BountyValue=0;
        end

        if ( CurBounty  == 0 ) then  -- We have no bounty, whew!
                if ( FarmersToolkit.BountyValue > 0 ) then -- We may have a outstanding timer event tho
                        EVENT_MANAGER:UnregisterForUpdate(identifier)
                end

                FarmersToolkit.BountyValue = 0; -- Zero out internal counter / tracker
                FarmersToolkit.UpdateActivities(); -- Update the screen
                dft_debug("BountyCheck indicates you are safe as of " .. os.time() .. "!"); -- Debug
                dft("Bounty appears cleared, cancelling timers - happy hunting."); -- Announce
        else
                if ( ( FarmersToolkit.BountyValue == 0 ) and ( CurBounty > 0 ) ) then -- This is the onset of a bounty
                        dft("Bounty detected (" .. CurBounty .. "), updates posted to screen until cleared.");
                end
                FarmersToolkit.UpdateActivities();
                FarmersToolkit.BountyValue=CurBounty;
                dft_debug("BountyCheck = " .. CurBounty .. ", timer set for 15 seconds as of " .. os.time());
                EVENT_MANAGER:UnregisterForUpdate(identifier)  -- Just in case
                EVENT_MANAGER:RegisterForUpdate(identifier, 15000, FarmersToolkit.BountyCheck)
        end

end -- FarmersToolkit.BountyCheck
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Question on EVENT_JUSTICE_* firing


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