Hello there! We are conducting a survey to better understand the user experience in making a first edit. If you have ever made an edit on Gamepedia, please fill out the survey. Thank you!

AceEvent-2.0

From WowAce Wiki
Jump to: navigation, search

Example

MyAddon = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0")

-- not doing anything in OnInitialize, so we'll leave it out

function MyAddon:OnEnable()
    self:RegisterEvent("UNIT_BUFF") -- simple use of :RegisterEvent(),
    -- provided by AceEvent-2.0
    --
    -- self:RegisterEvent("UNIT_BUFF", "OnUnitBuff") would set the handler
    -- method to OnUnitBuff instead of UNIT_BUFF.
    --
    -- self:RegisterEvent("UNIT_BUFF", "UNIT_BUFF") is equivalent to
    -- self:RegisterEvent("UNIT_BUFF")
    --
    -- self:RegisterEvent("UNIT_BUFF", "UNIT_BUFF", true) would cause the
    -- handler to be called once and only once.
    
    self:RegisterEvent("OtherAddon_Explosion")
end

function MyAddon:UNIT_BUFF(person) -- called whenever the event is fired.
    print(string.format("%s's buffs have changed", person))
end

function MyAddon:DoSomething()
    self:TriggerEvent("MyAddon_SomethingHappened", 42)
    -- also provided by AceEvent-2.0, to allow open-ended radio-style
    -- communications between addons (or anything that inherits from
    -- AceEvent-2.0).
    --
    -- This works exactly like how normal events are triggered.
    -- self:TriggerEvent("event", ...)
    -- where "event" is the name of the event (typically prefixed by your
    -- addon's name).
    -- and ... is a list of arguments (from 0 to 20).
end

function MyAddon:OtherAddon_Explosion(kind)
    print(string.format("OtherAddon created a %s-type explosion", kind))
    
    if kind == "Nuclear" then
        self:UnregisterEvent("OtherAddon_Explosion")
        -- also provided by AceEvent-2.0, to unregister from events.
    end
    
    self:ScheduleEvent("MyAddon_ReactToExplosion", 1) -- fires off MyAddon_ReactToExplosion in 1 seconds
    self:ScheduleRepeatingEvent("MyAddon_Spasm", 1) -- spasm every second.
end


API Documentation

Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.

:CancelAllCombatSchedules()

No arguments

:CancelAllScheduledEvents()

No arguments

:CancelScheduledEvent(t)

Arguments

t
type - (needs documentation)


:IsBucketEventRegistered(event)

Arguments

event
type - (needs documentation)


:IsEventRegistered(event)

Arguments

event
type - (needs documentation)


:IsEventScheduled(t)

Arguments

t
type - (needs documentation)


:IsFullyInitialized()

No arguments string or function

:RegisterAllEvents([method])

Arguments

method
string or function - name of the method or function to call. Default: same name as "event".

Notes

  • Registers all events to the given method
  • To access the current event, check AceEvent.currentEvent
  • To access the current event's unique identifier, check AceEvent.currentEventUID
  • This is only for debugging purposes.


:RegisterBucketEvent(event , delay , method , ...)

Arguments

event
type - (needs documentation)
delay
type - (needs documentation)
method
type - (needs documentation)
...
type - (needs documentation)


string or function boolean

:RegisterEvent("event" [, method] [, once])

Arguments

"event"
string - name of the event to register
method
string or function - name of the method or function to call. Default: same name as "event".
once
boolean - whether to have method called only once. Default: false

Notes

  • Registers the addon with a Blizzard event or a custom AceEvent, which will cause the given method to be called when that is triggered.


:ScheduleEvent(event , delay , ...)

Arguments

event
string or function - name of the event to fire, or a function to call.
delay
number - the amount of time to wait until calling.
...
tuple - a list of arguments to pass along.

Notes

  • Schedule an event to fire.
  • To fire on the next frame, specify a delay of 0.


:ScheduleLeaveCombatAction(method , ...)

Arguments

method
type - (needs documentation)
...
type - (needs documentation)


:ScheduleRepeatingEvent(event , delay , ...)

Arguments

event
type - (needs documentation)
delay
type - (needs documentation)
...
type - (needs documentation)


:TriggerEvent("event" , ...)

Arguments

"event"
string - name of the event
...
tuple - list of arguments to pass along

Notes

  • Trigger a custom AceEvent.
  • This should never be called to simulate fake Blizzard events.
  • Custom events should be in the form of AddonName_SpecificEvent


:UnregisterAllBucketEvents()

No arguments

:UnregisterAllEvents()

No arguments

:UnregisterBucketEvent(event)

Arguments

event
type - (needs documentation)


:UnregisterEvent(event)

Arguments

event
type - (needs documentation)