AceEvent-2.0
From WowAce Wiki
[edit]
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
[edit]
API Documentation
Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.
[edit]
:CancelAllCombatSchedules()
No arguments
[edit]
:CancelAllScheduledEvents()
No arguments
[edit]
:CancelScheduledEvent(t)
[edit]
Arguments
- t
- type - (needs documentation)
[edit]
:IsBucketEventRegistered(event)
[edit]
Arguments
- event
- type - (needs documentation)
[edit]
:IsEventRegistered(event)
[edit]
Arguments
- event
- type - (needs documentation)
[edit]
:IsEventScheduled(t)
[edit]
Arguments
- t
- type - (needs documentation)
[edit]
:IsFullyInitialized()
No arguments string or function
[edit]
:RegisterAllEvents([method])
[edit]
Arguments
- method
- string or function - name of the method or function to call. Default: same name as "event".
[edit]
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.
[edit]
:RegisterBucketEvent(event , delay , method , ...)
[edit]
Arguments
- event
- type - (needs documentation)
- delay
- type - (needs documentation)
- method
- type - (needs documentation)
- ...
- type - (needs documentation)
string or function
boolean
[edit]
:RegisterEvent("event" [, method] [, once])
[edit]
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
[edit]
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.
[edit]
:ScheduleEvent(event , delay , ...)
[edit]
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.
[edit]
Notes
- Schedule an event to fire.
- To fire on the next frame, specify a delay of 0.
[edit]
:ScheduleLeaveCombatAction(method , ...)
[edit]
Arguments
- method
- type - (needs documentation)
- ...
- type - (needs documentation)
[edit]
:ScheduleRepeatingEvent(event , delay , ...)
[edit]
Arguments
- event
- type - (needs documentation)
- delay
- type - (needs documentation)
- ...
- type - (needs documentation)
[edit]
:TriggerEvent("event" , ...)
[edit]
Arguments
- "event"
- string - name of the event
- ...
- tuple - list of arguments to pass along
[edit]
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
[edit]
:UnregisterAllBucketEvents()
No arguments
[edit]
:UnregisterAllEvents()
No arguments
[edit]
:UnregisterBucketEvent(event)
[edit]
Arguments
- event
- type - (needs documentation)
[edit]
:UnregisterEvent(event)
[edit]
Arguments
- event
- type - (needs documentation)

