Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
 
 
Line 1: Line 1:
  +
{{npcbox
−
{{UIHowTo}}
 
  +
| name = Caylais Moonfeather
−
Events are messages sent by the WoW client to UI code (OnEvent script handlers of Frame derivatives), mostly in reaction to things occurring in the game world. To process events, an addon needs to create an event handler and register it for the events it wishes to receive.
 
  +
| image = Caylais dead.jpg
  +
| title = Hippogryph Master
  +
| level = 65
  +
| type = Elite
  +
| faction = Alliance
  +
| city = Darnassus
  +
| race = Night Elf
  +
| creature = Humanoid
  +
| sex = Female
  +
| status=Deceased
  +
| location = [[Ruins of Auberdine]], [[Darkshore]]
  +
}}
   
  +
'''Caylais Moonfeather''' was a level 65 [[hippogryph]] [[flight master]] located in [[Auberdine]] in the [[night elven]] zone of [[Darkshore]]. She has since been replaced by [[Teldira Moonfeather]] in [[Lor'danel]].
−
== Setting up an event handler ==
 
−
Events are sent to Frame-derived [[Widget API|widgets]]; an add-on needs to create a frame if it does not already own one that can be used for the purpose of handling events. Frames may be created in Lua using the [[API_CreateFrame|CreateFrame]] function; or constructed in XML (using the <Frame> tag).
 
   
  +
==In Cataclysm==
−
Once a frame has been created, its OnEvent handler must be set to a function that would handle the event on behalf of the addon. The OnEvent script handler may be set using the Lua frame:[[API_Frame_SetScript|SetScript]]() function; or constructed in XML (using <Scripts><OnEvent>function body</OnEvent></Scripts>). The OnEvent handler function receives at least two arguments:
 
  +
{{Cata-section}}
−
# self, a reference to the frame to which the script handler belongs
 
  +
[[File:Caylais Moonfeather.jpg|thumb|100px|left|Caylais as she was in life]]
−
# event, the name of the event being fired
 
  +
Caylais died during the destruction of Auberdine in Cataclysm, and her body can be found near where she used to stand, surrounded by the corpses of three [[enraged hippogryph]]s.
−
# The remaining event arguments are placed within the vararg expression (...). You can extract variables from the vararg expression by simply assigning it to your local variables: <code>local arg1, arg2, arg3 = ...;</code>
 
−
The addon's OnEvent script handler function should either handle the event, or call another addon function to handle the event.
 
   
  +
When inspecting her body during ''[[Quest:Coaxing the Spirits|Coaxing the Spirits]]'', it is stated that being far too powerful for the air elementals, Caylais and her hippogryphs must have been struck down by something else, suggesting that they've been killed maybe by members of the [[Twilight's Hammer]].
−
In order to receive event notifications, the event handler frame needs to be registered for events the addon needs to handle; use frame:[[API_Frame_RegisterEvent|RegisterEvent]]("eventName") to achieve this. The RegisterEvent function can can be called at any time after the frame's creation; the OnLoad script handler is a convenient location to register for the desired events when using XML.
 
   
  +
==External links==
−
If you no longer wish to receive event notifications for a particular event, use the frame:[[API_Frame_UnregisterEvent|UnregisterEvent]]() function. If you wish to disable all event notifications currently delivered to a frame, use the frame:[[API_Frame_UnregisterAllEvents|UnregisterAllEvents]]().
 
  +
{{Elinks-NPC|33037}}
   
  +
{{DEFAULTSORT:Moonfeather, Caylais}}
−
== Examples ==
 
  +
[[Category:Night elves]]
−
===Hello World===
 
  +
[[Category:Darkshore NPCs]]
−
The two implementations below are functionally identical: they print "Hello World! Hello PLAYER_ENTERING_WORLD" to the default chat frame when the character zones into the world. Note that the event variable is implicit in the XML OnEvent handler: it is supplied by the OnEvent closure signature.
 
  +
[[Category:Deceased characters]]
−  
−
'''Using XML'''
 
−
<Ui>
 
−
<Frame name="FooAddonFrame">
 
−
<Scripts>
 
−
<OnLoad> self:RegisterEvent("PLAYER_ENTERING_WORLD"); </OnLoad>
 
−
<OnEvent> print("Hello World! Hello " .. event); </OnEvent>
 
−
</Scripts>
 
−
</Frame>
 
−
</Ui>
 
−  
−
'''Using Lua'''
 
−
local frame = CreateFrame("FRAME", "FooAddonFrame");
 
−
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
 
−
local function eventHandler(self, event, ...)
 
−
print("Hello World! Hello " .. event);
 
−
end
 
−
frame:SetScript("OnEvent", eventHandler);
 
−  
−
=== XML-Specific ===
 
−
You may bind an already declared Lua function to the OnEvent handler in XML directly, rather than creating another function by providing a function body within the <OnEvent></OnEvent> tags. Doing so will save you memory:
 
−  
−
'''FooAddOn.lua'''
 
−
function FooHandler_OnEvent(self, event, ...)
 
−
-- insert event handling code here
 
−
end
 
−  
−
'''FooAddOn.xml'''
 
−
<Ui>
 
−
<Script file="FooAddon.lua"/>
 
−
<Frame name="FooHandler">
 
−
<Scripts>
 
−
<OnEvent function="FooHandler_OnEvent"/>
 
−
</Scripts>
 
−
</Frame>
 
−
</Ui>
 
−  
−
=== Lua-specific ===
 
−
If your frame registers a large number of events, you could reduce the required number of if clauses, and generally simplify your design by doing:
 
−
local frame, events = CreateFrame("Frame"), {};
 
−
function events:PLAYER_ENTERING_WORLD(...)
 
−
-- handle PLAYER_ENTERING_WORLD here
 
−
end
 
−
function events:PLAYER_LEAVING_WORLD(...)
 
−
-- handle PLAYER_LEAVING_WORLD here
 
−
end
 
−
frame:SetScript("OnEvent", function(self, event, ...)
 
−
events[event](self, ...); -- call one of the functions above
 
−
end);
 
−
for k, v in pairs(events) do
 
−
frame:RegisterEvent(k); -- Register all events for which handlers have been defined
 
−
end
 
−
Note that in the case of the events:XXX functions above, the variable self, implicitly defined by using the function table:functionName notation, will point to the frame handling the event rather than the events table.
 
−  
−
=== The vararg expression ===
 
−
The vararg expression (...) may contain additional arguments supplied by the event. Arguments contained in ... can be read by simply assigning them to other variables, possibly using the [[API_select|select]] function to skip forward to a specific argument in the list.
 
−  
−
Consider the example of handling [[API_COMBAT_LOG_EVENT|COMBAT_LOG_EVENT]]:
 
−
function eventHandler(self, event, ...)
 
−
if event == "COMBAT_LOG_EVENT" then
 
−
local timestamp, combatEvent, hideCaster, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags =
 
−
...; -- Those arguments appear for all combat event variants.
 
−
local eventPrefix, eventSuffix = combatEvent:match("^(.-)_?([^_]*)$");
 
−
if eventSuffix == "DAMAGE" then
 
−
-- Something dealt damage. The last 9 arguments in ... describe how it was dealt.
 
−
-- To extract those, we can use the select function:
 
−
local amount, overkill, school, resisted, blocked, absorbed, critical, glancing, crushing =
 
−
select(select("#", ...)-8, ...); -- select("#", ...) returns number of arguments in the vararg expression
 
−
-- Do something with the damage details ...
 
−
if eventPrefix == "RANGE" or eventPrefix:match("^SPELL") then
 
−
-- The first three arguments after destFlags in ... describe the spell or ability dealing damage.
 
−
-- Extract this data using select as well:
 
−
local spellId, spellName, spellSchool = select(10, ...); -- Everything from 10th argument in ... onward
 
−
-- Do something with the spell details ...
 
−
end
 
−
end
 
−
end
 
−
end
 
−  
−
== Notes ==
 
−
* The global this, event, and argX variables have been removed in [[Patch 4.0.1/API changes|Patch 4.0.1]]. Instead, use the arguments passed to the OnEvent script handler.
 
−  
−
== Relevant API ==
 
−
* [[API_CreateFrame|CreateFrame]]("widgetType"[, "name"[, parent[, "inherits"]]])
 
−
* frame:[[API_Frame_SetScript|SetScript]]("handlerType", func)
 
−
* frame:[[API_Frame_HookScript|HookScript]]("handlerType", func)
 
−
* frame:[[API_Frame_RegisterEvent|RegisterEvent]]("eventName") (and possibly frame:[[API_Frame_RegisterAllEvents|RegisterAllEvents]]() )
 
−
* frame:[[API_Frame_UnregisterEvent|UnregisterEvent]]("eventName") (and possibly frame:[[API_Frame_UnregisterAllEvents|UnregisterAllEvents]]() )
 
−
* [[Events (API)]], a listing of events you may subscribe to.
 

Revision as of 11:15, 16 June 2011

AllianceCaylais Moonfeather
Image of Caylais Moonfeather
Title <Hippogryph Master>
Race Night Elf (Humanoid)
Level 65 Elite
Affiliation(s) Darnassus
Location Ruins of Auberdine, Darkshore
Status Deceased

Caylais Moonfeather was a level 65 hippogryph flight master located in Auberdine in the night elven zone of Darkshore. She has since been replaced by Teldira Moonfeather in Lor'danel.

In Cataclysm

Cataclysm This section concerns content related to Cataclysm.
Caylais Moonfeather

Caylais as she was in life

Caylais died during the destruction of Auberdine in Cataclysm, and her body can be found near where she used to stand, surrounded by the corpses of three enraged hippogryphs.

When inspecting her body during Coaxing the Spirits, it is stated that being far too powerful for the air elementals, Caylais and her hippogryphs must have been struck down by something else, suggesting that they've been killed maybe by members of the Twilight's Hammer.

External links