<<

APPENDIX A

Frame Reference

This appendix contains information on all the frame types that you can create in World of , with all the XML attributes and elements as well as all Lua methods and available script handlers. Frame types follow an object-oriented model, meaning that a frame type can inherit attributes and methods from another frame type. You can find an introduction to object-oriented programming in Chapter 6 if you are not familiar with this topic. You may wonder why there is such an appendix in this book, as you can probably find most of the information covered here on the Internet. WoWWiki has a few good pages that deal with exactly the same topic as this appendix. However, the information there is scattered over multiple pages and many of the articles are outdated or incomplete. This appendix is up to date as of patch 3.1 (the next patches probably won’t change anything important in the frame API) and contains everything you need to know about a particular frame type in one place.

Object K^fa_p is an abstract frame type; that is, you cannot create frames from this type. But this type is the base class for all other frame types as every other type inherits from K^fa_p. This means that all of the methods, XML attributes, and XML elements listed here are available for all frames. This frame type is sometimes also called QEK^fa_p, which is probably the type’s internal name used in the C++ code of the game.

XML Attributes The K^fa_p type has the following XML attributes.

]hld] Defines the frame’s transparency (0 – 1). Default: 1.

405 406 APPENDIX A N FRAME REFERENCE

l]najp Defines the frame’s parent.

j]ia Defines the frame’s name.

ejdanepo The template to use.

renpq]h Creates a template. Default: b]hoa.

Lua Methods The K^fa_p type has the following Lua methods.

k^fa_p6Cap=hld]$% Returns the frame’s alpha value.

k^fa_p6CapAbba_pera=hld]$% Returns the frame's effective alpha value by multiplying its alpha value with the parent’s effective alpha.

k^fa_p6CapJ]ia$% Returns the name of the frame.

k^fa_p6CapK^fa_pPula$% Returns the type of the k^fa_p.

k^fa_p6CapL]najp$% Returns the parent of the frame.

k^fa_p6EoK^fa_pPula$k^fPula% Returns 1 if k^fa_p is of the type k^fPula, or of a type that inherits from k^fPula. For example, ?na]paBn]ia$?da_g>qppkj%6EoK^fa_pPula$>qppkj% returns 1 because the type ?da_g>qppkj inherits from the type >qppkj.

k^fa_p6Oap=hld]$% Sets the frame’s transparency (0 – 1). APPENDIX A N FRAME REFERENCE 407 k^fa_p6OapL]najp$k^f% Sets the frame’s parent.

Font Bkjp is an object that inherits from K^fa_p and represents a font that can be used by BkjpOpnejcs or >qppkjs.

XML Attributes The Bkjp type has the following XML attributes. bkjp The path to the font file you want to use. fqopebuD Sets the horizontal justification setting. This can either be HABP, NECDP, or ?AJPAN. Default: ?AJPAN. fqopebuR Sets the vertical justification setting. This can either be >KPPKI, PKL, or IE@@HA. Default: IE@@HA. ikjk_dnkia Uses a monochrome font. Default: b]hoa. kqpheja The outline to use; can be JKJA, JKNI=H, or PDE?G. Default: JKJA. ol]_ejc The spacing between characters. Default: 0.

XML Elements The Bkjp type has the following XML elements.

BkjpDaecdp Controls the height of the font with its R]hqa attribute.

?khkn Controls the color of the font with its n, c, ^, and ] attributes. 408 APPENDIX A N FRAME REFERENCE

Od]`ks Contains the two elements ?khkn and Kbboap. ?khkn controls the color with the attributes n, c, ^, and ], and Kbboap controls the shadow offset with one of the elements =^o@eiajoekj or Nah@eiajoekj.

Lua Methods The Bkjp type has the following Lua methods.

bkjp6?kluBkjpK^fa_p$kpdanK^fa_p% Copies all settings from kpdanK^fa_p.

bkjp6CapBkjp$% Returns the font file used.

bkjp6CapBkjpK^fa_p$% Returns the font object itself. This method makes sense when called from a frame that inherits from Bkjp.

bkjp6CapFqopebuD$% Returns the horizontal alignment of the text.

bkjp6CapFqopebuR$% Returns the vertical alignment of the text.

bkjp6CapIqhpehejaEj`ajp$% Returns the multiline indention setting.

bkjp6CapOd]`ks?khkn$% Returns the color of the font’s shadow.

bkjp6CapOd]`ksKbboap$% Returns the offset of the shadow.

bkjp6CapOl]_ejc$% Returns the spacing between characters.

bkjp6CapPatp?khkn$% Returns the color of the text. APPENDIX A N FRAME REFERENCE 409 bkjp6OapBkjp$l]pd% Sets the font file to use. bkjp6OapBkjpK^fa_p$bkjp% This method makes sense only when called from a frame (such as a Iaoo]caBn]ia) that inherits from a Bkjp. This method can then set or change the used font object for the text of the frame. bkjp6OapFqopebuD$]hecj% Sets the horizontal justification setting. The ]hecj argument can be HABP, NECDP, or ?AJPAN. bkjp6OapFqopebuR$]hecj% Sets the vertical justification setting. The ]hecj argument can be PKL, >KPPKI, or IE@@HA. bkjp6OapIqhpehejaEj`ajp$ej`ajp% Controls whether to indent the continuation of a string that does not fit in a single line. bkjp6OapOd]`ks?khkn$n(c(^(]% Sets the color of the shadow. bkjp6OapOd]`ksKbboap$t(u% Sets the offset of the shadow. bkjp6OapOl]_ejc$j% Sets the spacing between characters. bkjp6OapPatp?khkn$n(c(^(]% Sets the color of the text.

Region Nacekj inherits from K^fa_p. The only way to create a Nacekj is by calling bn]ia6 ?na]paPephaNacekj$% or using the XML element PephaNacekj of a frame; you cannot use ?na]paBn]ia to create a Nacekj. It is the base class for everything that is visible on your screen (Bn]ia, Patpqna, and so on), as it defines sizes and anchors.

XML Attributes The Nacekj type has the following XML attributes. oap=hhLkejpo Fits the frame into its parent. Default: b]hoa. 410 APPENDIX A N FRAME REFERENCE

de``aj Defines whether the frame starts visible or hidden. Default: b]hoa.

XML Elements The Nacekj type has the following XML elements.

Oeva Oeva consists of either the element =^o@eiajoekj or Nah@eiajoekj. The former refers to an absolute size that depends only on the effective scale of the frame, while the latter refers to a size relative to the whole screen. Both have the attributes t and u that specify the actual size. A detailed description can be found in Chapter 5.

=j_dkno Consists of one or more Anchor elements. An anchor has the attributes Lkejp, Nah]peraLkejp, and Nah]peraPk and the element Kbboap which, like Oeva, consists of =^o@eiajoekj or Nah@eiajoekj and specifies the offset. A detailed description can be found in Chapter 5.

Lua Methods The Nacekj type has the following Lua methods.

nacekj6?ha]n=hhLkejpo$% Removes all points but does not change the position. You have to set a new point in order to move the frame.

nacekj6Cap>kppki$% Returns the y coordinate of the frame’s bottom.

nacekj6Cap?ajpan$% Returns the x and y coordinates of the frame’s center.

nacekj6CapDaecdp$% Retrieves the frame’s height.

nacekj6CapHabp$% Returns the x coordinate of the frame’s left border.

nacekj6CapJqiLkejpo$% Returns the number of anchor points. APPENDIX A N FRAME REFERENCE 411 nacekj6CapLkejp$j% Retrieves the jth point of the frame. The return values are equivalent to the arguments passed to OapLkejp when creating the anchor. nacekj6CapNa_p$% Returns the frame’s bottom left x and y coordinates followed by the width and height. nacekj6CapPkl$% Returns the y coordinate of the frame’s top. nacekj6CapSe`pd$% Returns the width of the frame. nacekj6De`a$% Hides the frame. nacekj6EoLnkpa_pa`$% Returns 1 if the frame is a protected frame. nacekj6EoOdksj$% Determines whether the frame is shown. This does not take the frame’s parent into account; see EoReoe^ha. nacekj6EoReoe^ha$% Determines whether the frame and all of its parents (and grandparents, and so on) are shown. nacekj6Oap=hhLkejpo$bn]ia% Stretches the frame to fit into bn]ia. nacekj6OapDaecdp$daecdp% Sets the frame’s height. nacekj6OapLkejp$lkejp(nah]peraBn]ia(nah]peraLkejp(t(u% Adds an anchor point. See Chapter 5 for a detailed description. nacekj6OapSe`pd$se`pd% Sets the frame’s width. 412 APPENDIX A N FRAME REFERENCE

nacekj6Opkl=jei]pejc$% Stops all currently playing animations.

nacekj6Cap=jei]pekjCnkqlo$% Returns all animation groups of the frame.

nacekj6?na]pa=jei]pekjCnkql$j]ia(ejdanepo% Creates a new animation group for the frame.

nacekj6Eo@n]ccejc$% Determines whether the user is currently dragging the frame or its parent.

nacekj6?]j?d]jcaLnkpa_pa`Op]pa$% Determines whether you are allowed to call a protected method from tainted code at the moment.

Frame Bn]ia inherits from Nacekj, which means it has all the methods and attributes of K^fa_p and Nacekj.

XML Attributes The Bn]ia type has the following XML attributes.

pklharah Fits the frame into its parent. Default: b]hoa.

ikr]^ha Defines whether the frame starts visible or hidden. Default: b]hoa.

naoev]^ha Makes the frame resizable. Default: b]hoa.

bn]iaOpn]p] Defines the frame strata. Frame strata are described in Chapter 5.

bn]iaharah Defines the level of the frame. APPENDIX A N FRAME REFERENCE 413 aj]^haIkqoa Enables mouse input. Default: b]hoa. aj]^haGau^k]n` Enables keyboard input. Default: b]hoa.

_h]ila`PkO_naaj Prevents the frame from being dragged off the screen. Default: b]hoa. fqilJ]rec]paAj]^ha` Allows the element to be selected with a gamepad or joystick. fqilJ]rec]paOp]np Sets the frame as first frame to be selected when using a gamepad or joystick. Default: b]hoa.

XML Elements The Bn]ia type has the following XML elements.

PephaNacekj A frame of the type Nacekj, which is used as the title region of the frame.

Naoeva>kqj`o Consists of the two elements IejNaoeva and I]tNaoeva, which can contain an =^o@eiajoekj or a Nah@eiajoekj element defining the minimum and maximum size of the frame.

>]_g`nkl Defines the backdrop. A detailed description is available in Chapter 5.

DepNa_pEjoapo Sets the rectangle in which the frame accepts mouse clicks via the attributes left, right, top, and bottom.

H]uano Contains multiple H]uan elements, which in turn may contain multiple Patpqnas or BkjpOpnejcs. A detailed description is available in Chapter 5.

Bn]iao Contains multiple frames of any type that inherits from Bn]ia. 414 APPENDIX A N FRAME REFERENCE

O_nelpo Contains the script handlers.

Lua Methods The Bn]ia type has the following Lua methods.

bn]ia6=hhks=ppne^qpa?d]jcao$% A protected method. Allows tainted code to change attributes in the current execution path while in combat.

bn]ia6?na]paBkjpOpnejc$j]ia(h]uan(ejdanepoBnki% Creates a new BkjpOpnejc object in the layer h]uan as child of the frame.

bn]ia6?na]paPatpqna$% Creates a new Patpqna object in the layer as child of the frame.

bn]ia6?na]paPephaNacekj$% Creates a new PephaNacekj, a frame of the type Nacekj. A title region comes with predefined script handlers (unchangeable, because OapO_nelp doesn’t exist for Nacekjs) for Kj@n]cOp]np and Kj@n]cOpkl; these handlers call Op]npIkrejc and OpklIkrejcKnOevejc respectively on the Nacekj’s parent if it is movable.

bn]ia6@eo]^ha@n]sH]uan$h]uanHarah% Hides the given layer level.

bn]ia6Aj]^ha@n]sH]uan$h]uanHarah% Displays the given layer level.

bn]ia6Aj]^haFkuope_g$% Enables joystick and gamepad input for the frame.

bn]ia6Aj]^haGau^k]n`$% Enables keyboard events.

bn]ia6Aj]^haIkqoa$% Enables mouse events.

bn]ia6Aj]^haIkqoaSdaah$% Enables mouse wheel events. APPENDIX A N FRAME REFERENCE 415 bn]ia6Cap=ppne^qpa$]ppn% Returns the value of ]ppn. bn]ia6Cap>]_g`nkl$% Returns the frame’s backdrop as a table in the same format as Oap>]_g`nkl expects it. bn]ia6Cap>]_g`nkl>kn`an?khkn$% Returns the color of the backdrop’s border. bn]ia6Cap>]_g`nkl?khkn$% Returns the color of the backdrop. bn]ia6Cap>kqj`oNa_p$% Like CapNa_p but takes the frame’s layers into account. bn]ia6Cap?deh`naj$% Returns how many children the frame has. bn]ia6Cap?h]ilNa_pEjoapo$% Returns all children of the frame. bn]ia6Cap@alpd$% Get the frame’s depth on 3D monitors. bn]ia6CapAbba_pera@alpd$% Returns the frame’s effective depth by taking the parent’s depth into account. bn]ia6CapAbba_peraO_]ha$% Returns the effective scale of the frame. bn]ia6CapBn]iaHarah$% Returns the frame level, which determines whether a frame is in front of or behind another frame in the same stratum. bn]ia6CapBn]iaOpn]p]$% Returns the stratum the frame is in. bn]ia6CapDepNa_pEjoapo$% Returns the rectangle that defines where the frame can be clicked. 416 APPENDIX A N FRAME REFERENCE

bn]ia6CapI]tNaoeva$% Returns the maximum width and height the frame can be resized to by the user.

bn]ia6CapIejNaoeva$% Returns the minimum width and height.

bn]ia6CapJqi?deh`naj$% Returns all children of the frame.

bn]ia6CapJqiNacekjo$% Returns the number of regions in the frame.

bn]ia6CapNacekjo$% Returns all regions (Patpqnas and BkjpOpnejcs) of the frame.

bn]ia6CapO_]ha$% Returns the frame’s scale.

bn]ia6CapO_nelp$o_nelp% Returns the function assigned to O_nelpD]j`han.

bn]ia6CapPephaNacekj$% Returns the title region of the frame.

bn]ia6D]oO_nelp$o_nelp% Determines whether the frame can have the script handler o_nelp.

bn]ia6DkkgO_nelp$o_nelp(bqj_% Hooks the script handler o_nelp with the function bqj_.

bn]ia6Ecjkna@alpd$ecjkna% Displays the frame in the default depth if ecjkna is pnqa.

bn]ia6Eo?h]ila`PkO_naaj$% Determines whether the frame is clamped to the screen.

bn]ia6EoArajpNaceopana`$arajp% Determines whether arajp is registered. APPENDIX A N FRAME REFERENCE 417 bn]ia6EoEcjknejc@alpd$% Returns pnqa if Ecjkna@alpd was called with pnqa. bn]ia6EoFkuope_gAj]^ha`$% Returns pnqa if the frame accepts joystick and gamepad input. bn]ia6EoFqilJ]rec]paAj]^ha`$% Determines whether the frame can be selected with a joystick or gamepad. bn]ia6EoFqilJ]rec]paOp]np$% Returns 1 if the frame is the first frame that is selected in an environment with a gamepad or joystick instead of a mouse. bn]ia6EoGau^k]n`Aj]^ha`$% Returns 1 if the frame receives keyboard events. bn]ia6EoIkqoaAj]^ha`$% Returns 1 if the frame receives mouse events. bn]ia6EoIkqoaSdaahAj]^ha`$% Returns 1 if the frame receives mouse wheel events. bn]ia6EoIkr]^ha$% Returns 1 if the frame is movable. bn]ia6EoNaoev]^ha$% Returns 1 if the frame is resizable. bn]ia6EoPklharah$% Returns 1 if the frame is a top-level frame. bn]ia6EoQoanLh]_a`$% Returns 1 if the qoanlh]_a` attribute is set. bn]ia6Hksan$% Reduces the frame’s level. bn]ia6N]eoa$% Increases the frame’s level. 418 APPENDIX A N FRAME REFERENCE

bn]ia6Naceopan=hhArajpo$% Registers all available events for debugging purposes.

bn]ia6NaceopanArajp$arajp% Registers the given event.

bn]ia6NaceopanBkn@n]c$^pj-(***% Enables the Kj@n]cOp]np/Opkl handlers for the given mouse buttons.

bn]ia6Oap=ppne^qpa$]ppne^qpa(r]hqa% Sets ]ppne^qpa to r]hqa.

bn]ia6Oap>]_g`nkl$^]_g@nkl% Sets the frame’s backdrop; ^]_g@nkl is a table in the following format:

w ^cBeha9^cBeha(a`caBeha9a`caBeha(peha9b]hoa( pehaOeva9-2(a`caOeva9/.( ejoapo9whabp9,(necdp9,(pkl9,(^kppki9,y y

A description of backdrops can be found in Chapter 5.

bn]ia6Oap>]_g`nkl>kn`an?khkn$n(c(^(]% Sets the border color of the backdrop.

bn]ia6Oap>]_g`nkl?khkn$n(c(^(]% Sets the background color of the background.

bn]ia6Oap?h]ilNa_pEjoapo$t(u(se`pd(daecdp% Sets the rectangle that is used to determine whether the frame is on or off the screen.

bn]ia6Oap?h]ila`PkO_naaj$_h]ila`% Prevents the user from dragging the frame off the screen.

bn]ia6Oap@alpd$`alpd% Sets the frame’s depth on 3D monitors.

bn]ia6OapBn]iaHarah$harah% Sets the frame’s level. APPENDIX A N FRAME REFERENCE 419 bn]ia6OapBn]iaOpn]p]$opn]p]% Sets the frame’s strata. bn]ia6OapDepNa_pEjoapo$t(u(se`pd(daecdp% Sets the rectangle in which the frame accepts mouse clicks. bn]ia6OapE@$e`% Sets the ID of the frame. bn]ia6OapFqilJ]rec]paAj]^ha`$aj]^ha`% Makes the frame selectable with a gamepad or joystick. bn]ia6OapI]tNaoeva$se`pd(daecdp% Sets the maximum size of the frame. bn]ia6OapIejNaoeva$se`pd(daecdp% Sets the minimum size of the frame. bn]ia6OapIkr]^ha$ikr]^ha% Makes the frame movable with Op]npIkrejc. bn]ia6OapNaoev]^ha$ikr]^ha% Makes the frame resizable. bn]ia6OapO_]ha$o_]ha% Sets the scale of the frame. bn]ia6OapO_nelp$o_nelp(bqj_% Sets the script handler for o_nelp to bqj_. bn]ia6OapPklharah$pklHarah% Makes the frame a top-level frame. bn]ia6OapQoanLh]_a`$qoanLh]_a`% Saves the position of the frame. bn]ia6Op]npIkrejc$% Attaches the frame to your mouse cursor. 420 APPENDIX A N FRAME REFERENCE

bn]ia6Op]npOevejc$% Starts to resize the frame.

bn]ia6OpklIkrejcKnOevejc$% Stops resizing or moving the frame.

bn]ia6Qjnaceopan=hhArajpo$% Unregisters all events.

bn]ia6QjnaceopanArajp$arajp% Unregisters the given event.

Script Handlers The Frame type has the following script handlers.

Kj=jeiBejeoda`$oahb% Kj=ppne^qpa?d]jca`$oahb(]ppne^qpaJ]ia(r]hqa% Kj?qnokn?d]jca`$oahb(t(u(s(d% Kj@kq^ha?he_g$oahb(^qppkj% Kj@n]cOp]np$oahb(^qppkj% Kj@n]cOpkl$oahb% KjAjpan$oahb(ikpekj% KjAjpanLnaooa`$oahb% KjAo_]laLnaooa`$oahb% KjArajp$oahb(arajp(***% KjDe`a$oahb% KjGau@ksj$oahb(gau% KjGauQl$oahb(gau% KjHa]ra$oahb(ikpekj% KjHk]`$oahb% KjIkqoa@ksj$oahb(^qppkj% KjIkqoaQl$oahb(^qppkj% KjIkqoaSdaah$oahb(`ahp]% KjNa_aera@n]c$oahb% KjOdks$oahb% KjOeva?d]jca`$oahb(se`pd(daecdp% APPENDIX A N FRAME REFERENCE 421

KjOl]_aLnaooa`$oahb% KjP]^Lnaooa`$oahb% KjQl`]pa$oahb(ah]loa`%

FontString BkjpOpnejc inherits from Nacekj. You cannot create a BkjpOpnejc via ?na]paBn]ia; you have to create it by calling the method ?na]paBkjpOpnejc of a frame object or by defining it in the 8H]uano: element in the XML description of a frame. BkjpOpnejcs have all methods of Bkjps except for ?kluBkjpK^fa_p. However, BkjpOpnejcs do not inherit from Bkjp; bkjpopnejc6EoK^fa_pPula$Bkjp% returns jeh.

XML Attribute The BkjpOpnejc type has only one XML attribute. patp The text on the .

Lua Methods The BkjpOpnejc type has the following Lua methods. bkjpOpnejc6?]jJkjOl]_aSn]l$% Returns 1 if the font string is set to wrap in the middle of a word. bkjpOpnejc6Cap@n]sH]uan$% Returns the layer the font string is in. Layers are explained in detail in Chapter 5. bkjpOpnejc6CapOpnejcDaecdp$% Returns the height needed by the font string. bkjpOpnejc6CapOpnejcSe`pd$% Returns the width of the font string. bkjpOpnejc6CapPatp$% Returns the displayed text. bkjpOpnejc6Oap=hld]Cn]`eajp$op]np(hajcpd% Creates an alpha gradient starting at op]np over hajcpd pixels. 422 APPENDIX A N FRAME REFERENCE

bkjpOpnejc6Oap@n]sH]uan$h]uan% Changes the draw layer.

bkjpOpnejc6OapBkni]ppa`Patp$bipOpn(***% Sets formatted text.

bkjpOpnejc6OapJkjOl]_aSn]l$jkjOl]_a% Controls whether the font string is allowed to wrap in the middle of a string.

bkjpOpnejc6OapPatp$patp% Sets the text.

bkjpOpnejc6OapPatpDaecdp$daecdp% Sets the text height.

bkjpOpnejc6OapRanpat?khkn$n(c(^(]% Sets the vertex color of the font string.

Texture Patpqna inherits from Nacekj. You cannot create a Patpqna via ?na]paBn]ia; you have to create it by calling the method ?na]paPatpqna of a frame object or by defining it in the 8H]uano: ele- ment in the XML description of a frame.

XML Attributes The Patpqna type has the following XML attributes.

]hld]Ik`a Controls the effect of the texture’s alpha channel. This can be one of the following values: @EO=>HA, >HAJ@ (default), =HLD=GAU, =@@, or IK@.

beha The file containing the texture to display.

XML Elements The Patpqna type has the following XML elements.

?khkn Sets the texture to a solid color, with the attributes n, c, ^, and ]. APPENDIX A N FRAME REFERENCE 423

Cn]`eajp Creates a gradient on the texture; the attribute kneajp]pekj of this element controls the ori- entation and can either be DKNEVKJP=H (default) or RANPE?=H. The two elements Iej?khkn and I]t?khkn of the Cn]`eajp element set the start and end color.

Pat?kkn`o Controls the texture coordinates with the attributes habp, necdp, pkl, and ^kppki.

Lua Methods The Patpqna type has the following Lua methods. patpqna6Cap>haj`Ik`a$% Returns the blend mode. patpqna6Cap@n]sH]uan$% Returns the draw layer. patpqna6CapPat?kkn`Ik`ebeaoNa_p$% Returns 1 if texture coordinates modify the display rectangle and jeh if they stretch the texture. patpqna6CapPatpqna$% Returns the path of the texture used. patpqna6CapRanpat?khkn$% Returns the vertex color. patpqna6Eo@ao]pqn]pa`$% Returns 1 if the texture is desaturated. patpqna6Oap>haj`Ik`a$% Sets the blend mode. patpqna6Oap@ao]pqn]pa`$`ao]pqn]pa`% Changes the desaturation state of the texture. patpqna6Oap@n]sH]uan$h]uan% Changes the draw layer. 424 APPENDIX A N FRAME REFERENCE

patpqna6OapCn]`eajp$kneajp]pekj(op]npN(op]npC(op]np>(aj`N(aj`C(aj`>% Creates a gradient over the whole texture. The kneajp]pekj argument can be either DKNEVKJP=H or RANPE?=H.

patpqna6OapCn]`eajp=hld]$kneajp]pekj(op]npN(op]npC(op]np>(op]np=(aj`N(aj`C( aj`>(aj`=% Same as OapCn]`eajp but with an additional alpha value.

patpqna6OapNkp]pekj$]jcha(_t(_u% Rotates the texture ]jcha degrees around the center point _t/_u, which is relative to the center of the texture. Default values for _t and _u are 0.

patpqna6OapPat?kkn`$habp(necdp(^kppki(pkl% Sets texture coordinates. Chapter 8 contains a detailed description.

patpqna6OapPat?kkn`Ik`ebeaoNa_p$ik`ebeao% Sets whether texture coordinates change the displayed part of the texture or stretch the texture.

patpqna6OapPatpqna$behaknn(c(^(]% Loads and displays the provided files or fills the texture with a solid color.

patpqna6OapRanpat?khkn$n(c(^(]% Sets the vertex color of the texture. You can think of the vertex color as a colored light shining on the texture.

Button >qppkj inherits from Bn]ia; it can be used to create clickable buttons.

XML Attributes The >qppkj type has only one XML attribute.

patp The text on the button.

XML Elements The >qppkj type has the following XML elements. APPENDIX A N FRAME REFERENCE 425

>qppkjPatp The font string that is used for the button’s text.

@eo]^ha`?khkn A color object (uses n, c, ^, and ] attributes); sets the vertex color for the disabled texture.

@eo]^ha`Bkjp Sets the font for the disabled button in its opuha attribute (expects the name of a Bkjp object).

@eo]^ha`Patpqna A texture object; sets the disabled button texture.

Decdhecdp?khkn A color object; sets the vertex color for the highlight texture.

DecdhecdpBkjp Sets the font for the highlighted button in its opuha attribute (expects the name of a Bkjp object).

DecdhecdpPatpqna A texture object. The highlight button texture.

Jkni]hBkjp Sets the font for the normal button in its opuha attribute (expects the name of a Bkjp object).

Jkni]hPatpqna A texture object; sets the normal button texture.

Lqoda`PatpKbboap A dimension object that defines the text offset when the button is pushed.

Lqoda`Patpqna A texture object; sets the pushed button texture.

Lua Methods The >qppkj type has the following Lua methods.

^qppkj6?he_g$% Executes the button’s Kj?he_g handler. 426 APPENDIX A N FRAME REFERENCE

^qppkj6@eo]^ha$% Disables the button.

^qppkj6Aj]^ha$% Enables the button.

^qppkj6Cap>qppkjOp]pa$% LQODA@ or JKNI=H.

^qppkj6Cap@eo]^ha`BkjpK^fa_p$% Returns the disabled font object.

^qppkj6Cap@eo]^ha`Patpqna$% Returns the disabled texture.

^qppkj6CapBkjpOpnejc$% Returns the used font string.

^qppkj6CapDecdhecdpBkjpK^fa_p$% Returns the highlight font object.

^qppkj6CapDecdhecdpPatpqna$% Returns the highlight texture.

^qppkj6CapJkni]hBkjpK^fa_p$% Returns the normal font object.

^qppkj6CapJkni]hPatpqna$% Returns the normal texture.

^qppkj6CapLqoda`PatpKbboap$% Returns the x and y offsets of the pushed text.

^qppkj6CapLqoda`Patpqna$% Returns the pushed texture.

^qppkj6CapPatp$% Returns the displayed text. APPENDIX A N FRAME REFERENCE 427

^qppkj6CapPatpDaecdp$% Returns the text’s height.

^qppkj6CapPatpSe`pd$% Returns the text’s width.

^qppkj6EoAj]^ha`$% Checks whether the button is enabled.

^qppkj6Hk_gDecdhecdp$% Shows the highlight texture.

^qppkj6NaceopanBkn?he_go$^pj-(***% Registers the given mouse buttons for click events.

^qppkj6Oap>qppkjOp]pa$% Sets the button’s state (JKNI=H or LQODA@).

^qppkj6Oap@eo]^ha`BkjpK^fa_p$bkjp% Sets the disabled font object.

^qppkj6Oap@eo]^ha`Patpqna$patpqna% Sets the disabled texture.

^qppkj6OapBkjpOpnejc$bjpOpn% Sets the BkjpOpnejc object used.

^qppkj6OapBkni]ppa`Patp$bkni]pOpn(***% Sets formatted text.

^qppkj6OapDecdhecdpBkjpK^fa_p$bkjp% Sets the highlight font object.

^qppkj6OapDecdhecdpPatpqna$patpqna% Sets the highlight texture.

^qppkj6OapJkni]hBkjpK^fa_p$bkjp% Sets the normal font object. 428 APPENDIX A N FRAME REFERENCE

^qppkj6OapJkni]hPatpqna$patpqna% Sets the normal texture.

^qppkj6OapLqoda`PatpKbboap$t(u% Sets the pushed text’s offsets.

^qppkj6OapLqoda`Patpqna$patpqna% Sets the pushed texture.

^qppkj6OapPatp$patp% Sets the displayed text.

^qppkj6Qjhk_gDecdhecdp$% Hides the highlight texture.

Script Handlers The >qppkj type has the following script handlers.

Lkop?he_g$oahb(^qppkj% Lna?he_g$oahb(^qppkj% Kj?he_g$oahb(^qppkj(`ksj%

CheckButton ?da_g>qppkj inherits from >qppkj and represents a check box.

XML Attributes The ?da_g>qppkj type has only one XML attribute.

_da_ga` Can be set to pnqa to check the button by default.

XML Elements The ?da_g>qppkj type has the following XML elements.

@eo]^ha`?da_ga`Patpqna A texture object; sets the texture that is shown on disabled checked buttons. APPENDIX A N FRAME REFERENCE 429

?da_ga`Patpqna A texture object; sets the texture that is shown on normal checked buttons.

Lua Methods The ?da_g>qppkj type has the following Lua methods.

_da_g>qppkj6Cap?da_ga`$% Returns 1 if the button is checked.

_da_g>qppkj6Cap?da_ga`Patpqna$% Returns the texture object of checked buttons.

_da_g>qppkj6Cap@eo]^ha`?da_ga`Patpqna$% Returns the texture object of disabled checked buttons.

_da_g>qppkj6Oap?da_ga`$_da_ga`% Sets the check button to _da_ga`.

_da_g>qppkj6Oap?da_ga`Patpqna$patpqna% Sets the normal checked texture.

_da_g>qppkj6Oap@eo]^ha`?da_ga`Patpqna$patpqna% Sets the disabled checked texture.

Cooldown ?kkh`ksj is the cooldown display that can be seen on action bars. It inherits from Bn]ia.

XML Attributes The ?kkh`ksj type has the following XML attributes. naranoa Set this to pnqa for a reverse cooldown. Default: b]hoa.

`n]sA`ca Set this to pnqa to draw edges around the cooldown display. Default: b]hoa.

Lua Methods The ?kkh`ksj type has the following Lua methods. 430 APPENDIX A N FRAME REFERENCE

_kkh`ksj6Oap?kkh`ksj$op]np(`qn]pekj% Displays a cooldown that started at start (timestamp as returned by CapPeia$% and CapOlahh?kkh`ksj$olahhJ]ia%) with the given duration in seconds.

_kkh`ksj6OapNaranoa$naranoa% Set this to pnqa for a reverse cooldown.

ColorSelect ?khknOaha_p is a frame that allows the user to pick a color. This frame type inherits from Bn]ia.

XML Elements The ?khknOaha_p type has the following XML attributes.

?khknSdaahPatpqna A texture object that is used for the color wheel.

?khknSdaahPdqi^Patpqna A texture object that is used for the color wheel thumbnail.

?khknR]hqaPatpqna A texture object that is used for the color selector.

?khknR]hqaPdqi^Patpqna A texture object that is used for the color selector thumbnail.

Lua Methods The ?khknOaha_p type has the following Lua methods.

_khknOaha_p6Cap?khknDOR$% Returns the selected color as HSV (hue, saturation, value) values.

_khknOaha_p6Cap?khknNC>$% Returns the selected color as RGB.

_khknOaha_p6Cap?khknR]hqaPatpqna$% Returns the color value texture object. APPENDIX A N FRAME REFERENCE 431

_khknOaha_p6Cap?khknR]hqaPdqi^Patpqna$% Returns the color value thumbnail texture object.

_khknOaha_p6Cap?khknSdaahPatpqna$% Returns the color wheel texture.

_khknOaha_p6Cap?khknSdaahPdqi^Patpqna$% Returns the color wheel thumbnail texture.

_khknOaha_p6Oap?khknDOR$d(o(r% Sets the selected color to the given HSV value.

_khknOaha_p6Oap?khknNC>$n(c(^% Sets the selected color to the given RGB value.

_khknOaha_p6Oap?khknR]hqaPatpqna$patpqna% Sets the color value texture.

_khknOaha_p6Oap?khknR]hqaPdqi^Patpqna$% Sets the color value thumb texture.

_khknOaha_p6Oap?khknSdaahPatpqna$% Sets the color wheel texture.

_khknOaha_p6Oap?khknSdaahPdqi^Patpqna$% Sets the color wheel thumb texture.

Script Handlers The ?khknOaha_p type has only one script handler.

Kj?khknOaha_p$oahb(n(c(^%

EditBox A`ep>kt is a frame that allows the user to enter text. It inherits from Bn]ia. A`ep>ktes have all methods of Bkjps except for ?kluBkjpK^fa_p. However, A`ep>ktes do not inherit from Bkjp; a`ep>kt6EoK^fa_pPula$Bkjp% returns jeh. 432 APPENDIX A N FRAME REFERENCE

XML Attributes The A`ep>kt type has the following XML attributes.

]qpkbk_qo Automatically grabs the focus when it is shown. Default: b]hoa.

^hejgOlaa` The blink speed of the cursor. Default: 0.5.

deopknuHejao Determines how many history lines will be saved. Default: 0.

ecjkna=nnkso Ignores the arrow keys so you can still move with them while the edit box has the focus. Default: b]hoa.

happano The maximum number of allowed letters. Default 0: (meaning no limit).

iqhpeHeja Creates a multiple-line edit box. Default: b]hoa.

jqiane_ Accepts only numbers. Default: b]hoa.

XML Elements The A`ep>kt type has the following two XML attributes.

Decdhecdp?khkn A color element that sets the color of highlighted text with its n, c, and ^ attributes.

PatpEjoapo Controls the padding between the text and border with its habp, necdp, pkl, and ^kppki attributes.

Lua Methods The A`ep>kt type has the following Lua methods.

a`ep>kt6=``DeopknuHeja$patp% Adds patp to the history. APPENDIX A N FRAME REFERENCE 433 a`ep>kt6?ha]nBk_qo$% Removes the focus from the edit box. a`ep>kt6Cap=hp=nnksGauIk`a$% Returns 1 if the edit box ignores the arrow keys. a`ep>kt6Cap>hejgOlaa`$% Returns the blink speed. a`ep>kt6Cap?qnoknLkoepekj$% Returns the cursor position. a`ep>kt6CapDeopknuHejao$% Returns the maximum number of history lines. a`ep>kt6CapEj`ajpa`Skn`Sn]l$% Returns the indented word wrap setting. a`ep>kt6CapEjlqpH]jcq]ca$% Returns the input language; NKI=J for non-Asian clients. a`ep>kt6CapI]t>upao$% Returns the maximum number of bytes the edit box can store. a`ep>kt6CapI]tHappano$% Returns the maximum number of letters the edit box can store. a`ep>kt6CapJqiHappano$% Returns the current number of letters. a`ep>kt6CapJqi^an$% Tries to interpret the entered text as a number. a`ep>kt6CapPatpEjoapo$% Returns the text insets. a`ep>kt6D]oBk_qo$% Returns 1 if the edit box currently has the focus. 434 APPENDIX A N FRAME REFERENCE

a`ep>kt6DecdhecdpPatp$op]np(aj`% Highlights the text from op]np to aj`. Omit the arguments to highlight the whole text.

a`ep>kt6Ejoanp$patp% Inserts patp at the current position.

a`ep>kt6Eo=qpkBk_qo$% Returns 1 if the edit box automatically grabs the focus.

a`ep>kt6EoEjEIA?kilkoepekjIk`a$% Returns 1 if the IME mode is enabled. This is a feature for Asian clients.

a`ep>kt6EoIqhpeHeja$% Returns 1 for multiple-line edit boxes.

a`ep>kt6EoJqiane_$% Returns 1 for numeric edit boxes.

a`ep>kt6EoL]ooskn`$% Returns 1 for password edit boxes.

a`ep>kt6Oap=hp=nnksGauIk`a$ecjkna=nnkso% Sets the option whether to ignore arrow keys.

a`ep>kt6Oap=qpkBk_qo$]qpkBk_qo% Sets the auto focus option.

a`ep>kt6Oap>hejgOlaa`$^hejgOlaa`% Sets the cursor blink speed.

a`ep>kt6Oap?qnoknLkoepekj$lko% Sets the cursor position.

a`ep>kt6OapBk_qo$% Grabs the focus.

a`ep>kt6OapDeopknuHejao$j% Sets the maximum number of history lines. APPENDIX A N FRAME REFERENCE 435 a`ep>kt6OapEj`ajpa`Skn`Sn]l$sn]l% Sets the word wrap setting. a`ep>kt6OapI]t>upao$j% Sets the maximum number of bytes accepted by the edit box. a`ep>kt6OapI]tHappano$j% Sets the maximum number of letters accepted by the edit box. a`ep>kt6OapIqhpeHeja$iqhpeHejao% Creates a multiple-line edit box. a`ep>kt6OapJqi^an$j% Sets a numeric edit box to j. a`ep>kt6OapJqiane_$% Makes the edit box accept only numbers. a`ep>kt6OapL]ooskn`$% Hides entered characters. a`ep>kt6OapPatpEjoapo$habp(necdp(pkl(^kppki% Sets the padding between the text and the border of the edit box. a`ep>kt6PkcchaEjlqpH]jcq]ca$h]jcq]ca% Uses another input language; only important for Asian clients.

Script Handlers The A`ep>kt type has the following script handlers.

Kj?d]n$oahb(_d]n% Kj?d]n?kilkoepekj$oahb(_d]n% Kj?qnokn?d]jca`$oahb(t(u(se`pd(daecdp% KjA`epBk_qoC]eja`$oahb% KjA`epBk_qoHkop$oahb% KjEjlqpH]jcq]ca?d]jca`$oahb(h]jcq]ca% KjPatp?d]jca`$oahb% KjPatpOap$oahb% 436 APPENDIX A N FRAME REFERENCE

GameTooltip C]iaPkkhpel frames can be used as . This type inherits from Bn]ia. Tooltips are auto- matically resized as you add more lines with their methods.

Lua Methods The C]iaPkkhpel method has the following Lua methods.

c]iaPkkhpel6=``@kq^haHeja$habp(necdp(hN(hC(h>(nN(nC(n>% Adds a line with two font strings to the . hN, hC, and h> control the color of the left text habp and nN, nC, and n> the color of the right text code inline.

c]iaPkkhpel6=``BkjpOpnejco$habp(necdp% Adds a double line consisting of two font string objects to the tooltip.

c]iaPkkhpel6=``Heja$patp(n(c(^% Adds a new single line.

c]iaPkkhpel6=``Patpqna$patpqnaL]pd% Adds the given texture file.

c]iaPkkhpel6=llaj`Patp$patp% Appends patp to the end of the last line.

c]iaPkkhpel6B]`aKqp$% Fades the tooltip and hides it.

c]iaPkkhpel6?ha]nHejao$% Removes all content from the tooltip.

c]iaPkkhpel6Cap=j_dknPula$% Returns the current anchor type. These types are explained in Chapter 4.

c]iaPkkhpel6CapEpai$% Returns the name and link of the currently displayed item.

c]iaPkkhpel6CapIejeiqiSe`pd$% Returns the minimum width of the tooltip. APPENDIX A N FRAME REFERENCE 437 c]iaPkkhpel6CapKsjan$% Returns the tooltip’s owner. c]iaPkkhpel6CapL]``ejc$% Returns the padding to other objects. c]iaPkkhpel6CapOlahh$% Returns the currently displayed spell. c]iaPkkhpel6CapQjep$% Returns the currently displayed unit. c]iaPkkhpel6EoAmqella`Epai$% Returns 1 if the tooltip displays a currently equipped item. c]iaPkkhpel6EoKsja`$% Returns 1 if the tooltip has an owner. c]iaPkkhpel6EoQjep$% Returns 1 if the tooltip displays a unit. c]iaPkkhpel6JqiHejao$% Returns the maximum number of lines. c]iaPkkhpel6Oap=_pekj$ohkpE`% Shows the tooltip of a given action button slot. c]iaPkkhpel6Oap=j_dknPula$]j_dknPula(tKbboap(uKbboap% Sets an anchor type.

Setting Tooltip Contents The following methods deal with setting the tooltip to specific items or spells. There is no description of these methods, as the names and arguments are self-explanatory and the func- tions are rarely needed.

c]iaPkkhpel6Oap=q_pekjEpai$ej`at% c]iaPkkhpel6Oap=q_pekjOahhEpai$% c]iaPkkhpel6Oap>]_gl]_gPkgaj$e`% c]iaPkkhpel6Oap>]cEpai$^]`(ohkp% 438 APPENDIX A N FRAME REFERENCE

c]iaPkkhpel6Oap>qu^]_gEpai$e`% c]iaPkkhpel6Oap?qnnaj_uPkgaj$e`% c]iaPkkhpel6OapAmqeliajpOap$e`% c]iaPkkhpel6OapAteopejcOk_gapCai$e`% c]iaPkkhpel6OapChuld$e`% c]iaPkkhpel6OapCqeh`>]jgEpai$e`% c]iaPkkhpel6OapDulanhejg$hejg% c]iaPkkhpel6OapDulanhejg?kil]naEpai$hejg% c]iaPkkhpel6OapEj^ktEpai$e`% c]iaPkkhpel6OapEjrajpknuEpai$e`% c]iaPkkhpel6OapHkkpEpai$e`% c]iaPkkhpel6OapHkkpNkhhEpai$e`% c]iaPkkhpel6OapIan_d]jp?kopEpai$e`% c]iaPkkhpel6OapIan_d]jpEpai$e`% c]iaPkkhpel6OapLap=_pekj$e`% c]iaPkkhpel6OapMqaopEpai$mqaop(e`% c]iaPkkhpel6OapMqaopHkcEpai$e`% c]iaPkkhpel6OapMqaopHkcNas]n`Olahh$e`% c]iaPkkhpel6OapMqaopHkcOla_e]hEpai$e`% c]iaPkkhpel6OapMqaopNas]n`Olahh$e`% c]iaPkkhpel6OapOaj`I]ehEpai$e`% c]iaPkkhpel6OapOd]laodebp$e`% c]iaPkkhpel6OapOk_gapCai$e`% c]iaPkkhpel6OapOk_gapa`Epai$e`% c]iaPkkhpel6OapOlahh$olahhE`% c]iaPkkhpel6OapP]hajp$e`% c]iaPkkhpel6OapPkpai$e`% c]iaPkkhpel6OapPn]_gejc$e`% c]iaPkkhpel6OapPn]`aLh]uanEpai$e`% c]iaPkkhpel6OapPn]`aOgehhEpai$e`% c]iaPkkhpel6OapPn]`aP]ncapEpai$e`% c]iaPkkhpel6OapPn]ejanOanre_a$e`% c]iaPkkhpel6OapQjep$qE`% APPENDIX A N FRAME REFERENCE 439

c]iaPkkhpel6OapQjep=qn]$qE`(e(behpan% c]iaPkkhpel6OapQjep>qbb$qE`(e(behpan% c]iaPkkhpel6OapQjep@a^qbb$qE`(e(behpan% c]iaPkkhpel6OapIejeiqiSe`pd$se`pd% Sets the minimum width. c]iaPkkhpel6OapKsjan$bn]ia% Sets the owner of the tooltip. A tooltip is hidden when its owner is hidden. c]iaPkkhpel6OapL]``ejc$% Sets the padding.

MessageFrame Iaoo]caBn]ia is a frame that displays a few font strings; older font strings are hidden as you append new strings. It looks like a chat frame but without the scroll bars. Iaoo]caBn]ia has all methods of Bkjps except for ?kluBkjpK^fa_p. However, Iaoo]caBn]ia does not inherit from Bkjp; iaoo]caBn]ia6EoK^fa_pPula$Bkjp% returns jeh.

XML Attributes The Iaoo]caBn]ia method has the following XML attributes.

`eolh]u@qn]pekj The time after which an element is removed. b]`a Enables the fade out effect. Default: pnqa* b]`a@qn]pekj Duration of the fade effect. Default: 3.0. bkjp The font used. ejoanpIk`a Where to insert new messages; PKL or >KPPKI. Default: >KPPKI. 440 APPENDIX A N FRAME REFERENCE

XML Elements

The Iaoo]caBn]ia type has one available XML element.

patpEjoapo Controls the padding of the displayed text with the attributes habp, necdp, pkl, and ^kppki.

Lua Methods The Iaoo]caBn]ia type has the following Lua methods.

iaoo]caBn]ia6=``Iaoo]ca$ioc(n(c(^% Adds a message in the given color.

iaoo]caBn]ia6?ha]n$% Clears the frame.

iaoo]caBn]ia6CapB]`a@qn]pekj$% Returns the fade duration.

iaoo]caBn]ia6CapB]`ejc$% Returns the duration of the fade effect.

iaoo]caBn]ia6CapEjoanpIk`a$% Returns the insert mode.

iaoo]caBn]ia6CapPeiaReoe^ha$% Returns the time after which a message is hidden.

iaoo]caBn]ia6OapB]`a@qn]pekj$b]`a@qn]pekj% Sets the duration of the fade effect.

iaoo]caBn]ia6OapB]`ejc$b]`aKqp% Enables or disables the fade effect.

iaoo]caBn]ia6OapEjoanpIk`a$ejoanpIk`a% Sets the insert mode (PKL or >KPPKI).

iaoo]caBn]ia6OapPeiaReoe^ha$p% Sets the time after which a message is hidden. APPENDIX A N FRAME REFERENCE 441

Model Ik`ah is a frame that inherits from Bn]ia and displays a 3D model.

XML Attributes The Ik`ah type has the following XML attributes. beha The path of the model to display. bkcJa]n The near fog distance. Default: 0.0. bkcB]n The far fog distance. Default: 1.0. chks The glow intensity. Default: 1.0. o_]ha The scale of the model. This is a different value than the OapO_]ha/CapO_]ha scale.

XML Elements The Ik`ah type has only one XML attribute.

Bkc?khkn Controls the color of the fog with its n, c, ^, and ] attributes.

Lua Methods The Ik`ah type has the following Lua methods. ik`ah6=`r]j_aPeia$% This must be called by the KjQl`]pa handler if you want to play animations in the model. ik`ah6?ha]nBkc$% Removes the fog. ik`ah6?ha]nIk`ah$% Removes the model. 442 APPENDIX A N FRAME REFERENCE

ik`ah6CapB]_ejc$% Returns the direction the model is looking in.

ik`ah6CapBkc?khkn$% Returns the color of the fog.

ik`ah6CapBkcB]n$% Returns the maximum fog distance.

ik`ah6CapBkcJa]n$% Returns the minimum fog distance.

ik`ah6CapHecdp$% Returns the current light situation. The return values are the same as the arguments to OapHecdp.

ik`ah6CapIk`ah$% Returns the model used.

ik`ah6CapIk`ahO_]ha$% Returns the scale of the model.

ik`ah6CapLkoepekj$% Returns the position of the model inside the displayed scene.

ik`ah6Nalh]_aE_kjPatpqna$% Unknown.

ik`ah6Oap?]ian]$e`% Sets the camera to a camera that is defined in the model file.

ik`ah6OapB]_ejc$b]_ejc% Sets the facing to a radian value.

ik`ah6OapBkc?khkn$n(c(^(]% Sets the color of the fog.

ik`ah6OapBkcB]n$% Sets the fog’s far clip distance. APPENDIX A N FRAME REFERENCE 443 ik`ah6OapBkcJa]n$% Sets the fog’s near clip distance. ik`ah6OapChks$j% Sets the glow intensity. ik`ah6OapHecdp$aj]^ha`(kije(`enT(`enU(`enV(]i^Ejpajoepu(£ ]i^N(]i^>(`enEjpajoepu(`enN(`enC(`en>% Sets the light to use; all arguments except the first are optional. You will rarely have to call this as the default light is fine. ik`ah6OapIk`ah$l]pd% Sets the model file to use. ik`ah6OapIk`ahO_]ha$o_]ha% Scales the model. ik`ah6OapLkoepekj$t(u(v% Places the model at position x, y, and z in the displayed scene. ik`ah6OapOamqaj_a$e`% Sets the animation ID that will be played. This ID is defined in the model file. ik`ah6OapOamqaj_aPeia$e`(peia% Sets the model to a specific point in time of a specific sequence ID.

PlayerModel Lh]uanIk`ah is derived from Ik`ah and can be used to display players and NPCs.

Lua Methods The Lh]uanIk`ah type has the following Lua methods. lh]uanIk`ah6NabnaodQjep$% Refreshes the currently displayed unit; for example, to update the worn equipment. lh]uanIk`ah6Oap?na]pqna$_na]pqnaE`% Sets the model to display the given creature. This only works on creatures in your local cache, meaning creatures you have already seen. 444 APPENDIX A N FRAME REFERENCE

lh]uanIk`ah6OapNkp]pekj$nkp]pekj% Rotates the model.

lh]uanIk`ah6OapQjep$qjepE@% Displays the model of the given unit ID.

DressUpModel @naooQlIk`ah inherits from Lh]uanIk`ah and is a specialized version of it that provides func- tions to preview items.

Lua Methods The @naooQlIk`ah type has the following Lua methods.

lh]uanIk`ah6@naoo$% Equips the player’s default equipment.

lh]uanIk`ah6PnuKj$epai% Equips the given item link or item ID.

lh]uanIk`ah6Qj`naoo$% Undresses the displayed player.

TabardModel P]^]n`Ik`ah inherits from Lh]uanIk`ah and is a specialized version of it that provides functions to preview guild tabards.

Lua Methods The P]^]n`Ik`ah type has the following Lua methods.

p]^]n`Ik`ah6?]jO]raP]^]n`Jks$% Returns 1 if the tabard can be saved.

p]^]n`Ik`ah6?u_haR]ne]pekj$r]ne]pekjPula(ej`at% Cycles through the different available options.

p]^]n`Ik`ah6CapHksan>]_gcnkqj`BehaJ]ia$% Returns the filename of the lower background texture. APPENDIX A N FRAME REFERENCE 445 p]^]n`Ik`ah6CapHksanAi^haiBehaJ]ia$% Returns the filename of the lower emblem texture. p]^]n`Ik`ah6CapHksanAi^haiPatpqna$% Returns the lower emblem texture. p]^]n`Ik`ah6CapQllan>]_gcnkqj`BehaJ]ia$% Returns the filename of the upper background texture. p]^]n`Ik`ah6CapQllanAi^haiBehaJ]ia$% Returns the filename of the upper emblem texture. p]^]n`Ik`ah6CapQllanAi^haiPatpqna$% Returns the upper emblem texture. p]^]n`Ik`ah6Ejepe]hevaP]^]n`?khkno$% Initializes the tabard frame. p]^]n`Ik`ah6O]ra$% Saves the tabard.

ScrollFrame O_nkhhBn]ia inherits from Bn]ia and represents a scroll bar that can be used to scroll another frame.

XML Elements The O_nkhhBn]ia type has only one XML element.

O_nkhh?deh` An arbitrary frame that is scrolled by the scroll bar.

Lua Methods The O_nkhhBn]ia type has the following Lua methods. o_nkhhBn]ia6CapDknevkjp]hO_nkhh$% Returns the current scroll offset. 446 APPENDIX A N FRAME REFERENCE

o_nkhhBn]ia6CapDknevkjp]hO_nkhhN]jca$% Returns the maximum scroll range.

o_nkhhBn]ia6CapO_nkhh?deh`$% Returns the frame that is being scrolled by the scroll frame.

o_nkhhBn]ia6CapRanpe_]hO_nkhh$% Returns the vertical scroll offset.

o_nkhhBn]ia6CapRanpe_]hO_nkhhN]jca$% Returns the maximum vertical scroll range.

o_nkhhBn]ia6OapDknevkjp]hO_nkhh$kbboap% Sets the current horizontal scroll position.

o_nkhhBn]ia6OapO_nkhh?deh`$bn]ia% Sets bn]ia as the scroll child, that is, the frame that is being scrolled.

o_nkhhBn]ia6OapRanpe_]hO_nkhh$kbboap% Sets the current vertical scroll position.

o_nkhhBn]ia6Ql`]paO_nkhh?deh`Na_p$% Updates the displayed area of the scroll child. This method is called automatically when the user scrolls in your frame.

Script Handlers The O_nkhhBn]ia type has the following script handlers.

KjDknevkjp]hO_nkhh$oahb(kbboap% KjO_nkhhN]jca?d]jca`$oahb(tN]jca(uN]jca% KjRanpe_]hO_nkhh$oahb(kbboap%

ScrollingMessageFrame O_nkhhejcIaoo]caBn]ia is a frame type that is derived from Bn]ia; it can be used to display multiple messages with a scroll bar, as in a chat frame. O_nkhhejcIaoo]caBn]ia has all XML attributes and elements and Lua methods of Iaoo]caBn]ia. However, it is technically not a message frame, as o_nkhhejcIaoo]caBn]ia6 EoK^fa_pPula$Bkjp% returns jeh. The methods and attributes of Iaoo]caBn]ia are not listed here. APPENDIX A N FRAME REFERENCE 447

XML Attributes The O_nkhhejcIaoo]caBn]ia type has only one XML attribute. i]tHejao The maximum number of lines that can be added to the scroll frame. Default: 8.

Lua Methods The O_nkhhejcIaoo]caBn]ia type has the following Lua methods. o_nkhhejcIaoo]caBn]ia6=``Iaoo]ca$patp(n(c(^(e`(]``PkOp]np% Adds a message with the given color and ID. The ID can later be used to change the color of the message with Ql`]pa?khkn>uE@. The ]``PkOp]np argument can be used to insert the mes- sage at the opposite side from the default insert position. o_nkhhejcIaoo]caBn]ia6=p>kppki$% Determines whether the frame is scrolled to the very bottom. o_nkhhejcIaoo]caBn]ia6=pPkl$% Determines whether the frame is currently scrolled to the very top. o_nkhhejcIaoo]caBn]ia6Cap?qnnajpHeja$% Returns the line number of the last added message. Lines are zero-based; the first line has the line ID 0. Note that a message can consist of multiple lines. o_nkhhejcIaoo]caBn]ia6Cap?qnnajpO_nkhh$% Returns the number of messages that are currently not visible at the bottom. o_nkhhejcIaoo]caBn]ia6CapDulanhejgoAj]^ha`$% Determines whether are enabled or disabled in the scrolling message frame. o_nkhhejcIaoo]caBn]ia6CapI]tHejao$% Returns the maximum number of lines that can be displayed. o_nkhhejcIaoo]caBn]ia6CapJqiHejao@eolh]ua`$% Returns the number of lines that are currently visible in the frame. o_nkhhejcIaoo]caBn]ia6CapJqiIaoo]cao$% Returns the number of messages that were added to the scrolling message frame. 448 APPENDIX A N FRAME REFERENCE

o_nkhhejcIaoo]caBn]ia6L]ca@ksj$% Scrolls down by one page.

o_nkhhejcIaoo]caBn]ia6L]caQl$% Scrolls up by one page.

o_nkhhejcIaoo]caBn]ia6O_nkhh@ksj$% Scrolls down.

o_nkhhejcIaoo]caBn]ia6O_nkhhQl$% Scrolls up.

o_nkhhejcIaoo]caBn]ia6O_nkhhPk>kppki$% Scrolls to the bottom.

o_nkhhejcIaoo]caBn]ia6O_nkhhPkPkl$% Scrolls to the top.

o_nkhhejcIaoo]caBn]ia6OapDulanhejgoAj]^ha`$aj]^ha`% Enables or disables hyperlinks in the frame.

o_nkhhejcIaoo]caBn]ia6OapO_nkhhKbboap$kbboap% Scrolls to a given position from the bottom. Negative offsets will scroll to a position relative to the top.

o_nkhhejcIaoo]caBn]ia6Ql`]pa?khkn>uE@$e`(n(c(^% Changes the color of all messages inserted with the given e`.

SimpleHTML OeilhaDPIH is a frame type that is derived from Bn]ia; it allows you to display simple HTML. You can read the Wikipedia article dppl6++aj*segela`e]*knc+sege+DPIH if you are not familiar with HTML. The following elements are allowed in a OeilhaDPIH frame.

ÊU8]dnab9dulanhejg:patp8+]: to create links. Clicking on the link calls the KjDulanhejg?he_ga` handler with the usual arguments. It is not possible to use URLs here. ÊUÊ8^n+: to start a new line. APPENDIX A N FRAME REFERENCE 449

ÊUÊ8d-:, 8d.:, 8d/:, and 8l: for normal text. The attribute ]hecj can be used to control the text alignment and can be habp, necdp, or _ajpan. ÊUÊ8eicon_9patpqnaL]pd]hecj9habp+necdp+_ajpanse`pd9tdaecdp9u+: to embed images. All attributes except for on_ are optional.

You also need the obligatory 8dpih: and 8^k`u: tags or won’t recognize your code as HTML. Your text should look like this:

8dpih: 8^k`u: 8))ukqn_k`adana)): 8+^k`u: 8+dpih:

OeilhaDPIH has all the methods of Bkjp except for ?kluBkjpK^fa_p. But there is a small dif- ference: all Bkjp methods take an optional first parameter that can be either l, d-, d., or d/ to change the styles of the different available text types. The default value for this optional parameter is l. All XML attributes and elements of Bkjp are also available; they control the style of 8l: tags. The elements BkjpOpnejcDa]`an- – / can be used to set the style of 8d-: – 8d/: tags from XML.

XML Attributes The OeilhaDPIH type has the following XML attributes. beha An HTML file to load. dulanhejgBkni]p Defines how HTML links are displayed; this will be processed by opnejc*bkni]p with the first argument being the target of your link and the second the text. The default value is xD!oxd!oxd, which means your link is displayed like a regular in-game link. patp The HTML text to display.

XML Elements The OeilhaDPIH type has only one XML element.

BkjpOpnejcDa]`an- – / BkjpOpnejc objects that are used for d- – d/ styled texts.

Lua Methods The OeilhaDPIH type has the following Lua methods. 450 APPENDIX A N FRAME REFERENCE

oeilhaDPIH6CapDulanhejgBkni]p$% Returns the format.

oeilhaDPIH6CapDulanhejgoAj]^ha`$% Returns whether hyperlinks are enabled.

oeilhaDPIH6OapDulanhejgBkni]p$bip% Sets the hyperlink format.

oeilhaDPIH6OapDulanhejgoAj]^ha`$aj]^ha`% Enables or disables hyperlinks.

oeilhaDPIH6OapPatp$dpih% Sets the HTML to display.

Slider Ohe`an inherits from Bn]ia and is a frame type to input numeric values.

XML Attributes The Ohe`an type has the following XML attributes.

`ab]qhpR]hqa The default value of the . Caution: this triggers the script handler KjR]hqa?d]jca` before KjHk]` is called.

`n]sH]uan The layer in which the slider’s textures will be drawn. Default: KRANH=U.

i]tR]hqa The maximum value of the slider.

iejR]hqa The minimum value of the slider.

kneajp]pekj DKNEVKJP=H or RANPE?=H (default). APPENDIX A N FRAME REFERENCE 451 r]hqaOpal The step size.

XML Elements The Ohe`an type has the following XML elements.

Pdqi^Patpqna A texture object. This texture is used as a thumb (small draggable dot).

Lua Methods The Ohe`an type has the following Lua methods. ohe`an6@eoh]^a$% Disables the slider. ohe`an6Aj]^ha$% Enables the slider. ohe`an6CapIejI]tR]hqao$% Returns the minimum and maximum values that can be set by the user. ohe`an6CapKneajp]pekj$% Returns the orientation; can be either DKNEVKJP=H or RANPE?=H. ohe`an6CapPdqi^Patpqna$% Returns the thumb texture. ohe`an6CapR]hqa$% Returns the current value. ohe`an6CapR]hqaOpal$% Returns the step size. ohe`an6EoAj]^ha`$% Returns 1 if the slider is enabled. ohe`an6OapIejI]tR]hqao$iej(i]t% Sets the minimum and maximum values. 452 APPENDIX A N FRAME REFERENCE

ohe`an6OapKneajp]pekj$kneajp]pekj% Sets the orientation; can be DKNEVKJP=H or RANPE?=H.

ohe`an6OapPdqi^Patpqna$patpqna% Sets the thumb texture.

ohe`an6OapR]hqa$r]h% Sets the current value.

ohe`an6OapR]hqaOpal$% Sets the step size.

Script Handlers The Ohe`an type has only one script handler.

KjR]hqa?d]jca`$oahb(r]hqa%

StatusBar Op]pqo>]n inherits from Bn]ia and can be used to display progress, like a timer.

XML Attributes The Op]pqo>]n type has the following XML attributes.

`ab]qhpR]hqa The default value of the slider.

`n]sH]uan The layer in which the bar’s textures will be drawn. Default: =NPSKNG.

i]tR]hqa The maximum value of the bar.

iejR]hqa The minimum value of the bar.

kneajp]pekj DKNEVKJP=H or RANPE?=H (default). APPENDIX A N FRAME REFERENCE 453 nkp]paoPatpqna Can be set to pnqa to rotate the texture to fit the . Allows you to use horizontal tex- tures for vertical bars. Default: b]hoa.

XML Elements The Op]pqo>]n type has the following XML elements.

>]n?khkn Controls the color of the status bar with its n, c, ^, and ] attributes.

>]nPatpqna A texture object that is used for the status bar.

Lua Methods The Op]pqo>]n type has the following Lua methods. op]pqo>]n6CapIejI]tR]hqao$% Returns the minimum and maximum values of the bar. op]pqo>]n6CapKneajp]pekj$% Returns the orientation. op]pqo>]n6CapNkp]paoPatpqna$% Returns the rotate texture setting. op]pqo>]n6CapOp]pqo>]nPatpqna$% Returns the texture. op]pqo>]n6CapR]hqa$% Returns the current value. op]pqo>]n6OapIejI]tR]hqao$iej(i]t% Sets the minimum and maximum values. op]pqo>]n6OapKneajp]pekj$kneajp]pekj% Sets the orientation to either DKNEVKJP=H or RANPE?=H. op]pqo>]n6OapNkp]paoPatpqna$% Changes the texture rotation setting. 454 APPENDIX A N FRAME REFERENCE

op]pqo>]n6OapOp]pqo>]n?khkn$n(c(^(]% Changes the color of the bar.

op]pqo>]n6OapOp]pqo>]nPatpqna$patpqna% Changes the bar’s texture.

op]pqo>]n6OapR]hqa$r]hqa% Sets the value. APPENDIX B

Combat Log and Unit Reference

This appendix contains all the information you are ever going to need about the combat log and combat-related functions. You can probably find all the information presented here on the Internet (for example on WoWWiki), but it is scattered. It can be useful to have all the com- bat-related events and units in a single place. Combat Log Events The two combat log events ?KI>=P[HKC[ARAJP and ?KI>=P[HKC[ARAJP[QJBEHPANA@ have the same arguments; the only difference is that the unfiltered event is called for all combat log events, while the normal event is fired only for events that pass through your currently active combat log filter. You should always use the unfiltered event in your addon unless you are writing a combat log replacement that uses the combat log filter settings. These events receive numerous arguments (up to 20) based on the subevent. The basic event arguments are also covered in Chapter 9, which deals with the combat log. Standard Arguments As listed in Table B-1, there are eight standard arguments, which are always available.

Table B-1. The First Eight Combat Log Arguments Argument Name Description peiaop]il A timestamp that contains the exact time when the event occurred. This can be used as the second argument to `]pa$bip(peia%. arajp The subevent. okqn_aCQE@ The GUID (globally unique identifier) of the entity that generated the event. okqn_aJ]ia The name of the entity that generated the event. For example, if you cast a spell this is your name. okqn_aBh]co Flags that contain additional information about the entity that generated this event. Table B-11 later in this appendix shows how we can extract information from this bit field. `aopCQE@ The GUID of the target. `aopJ]ia The target’s name. `aopBh]co Flags of the target.

455 456 APPENDIX B N COMBAT LOG AND UNIT REFERENCE

Additional Arguments for the Prefixes OLAHH[ and N=JCA[ Table B-2 lists the arguments appended to all OLAHH[& and N=JCA[& subevents.

Table B-2. Additional Arguments of OLAHH and N=JCA Events Argument Name Description olahhE` The ID of the spell. This is the same ID that is also used by many WoW database sites, like . You can build a URL with the following pattern to retrieve additional information about a spell ID from such a site: dppl6++sss*sksda]`*_ki+;olahh98olahhE`: olahhJ]ia The name of the spell. olahhO_dkkh The school of the spell. This is a bit field.

Additional Argument for the Prefix AJRENKJIAJP=H[ The AJRENKJIAJP=H[& events define only one additional argument, the string ajrenkjiajp]hPula. This value is one of the following strings:

ÊUÊ@NKSJEJC ÊUÊB=HHEJC ÊUÊB=PECQA ÊUÊBENA ÊUÊH=R= ÊUÊOHEIA

Additional Arguments for the Suffix [@=I=CA All subevents that end in [@=I=CA receive the additional arguments listed in Table B-3.

Table B-3. Additional Arguments of Events with the Suffix [@=I=CA Argument Name Description ]ikqjp The amount of damage the attack did. krangehh The overkill damage if the target died from the attack. o_dkkh The school of the damage; like the spell’s school, this is a bit field. naoeopa` The amount of damage that was resisted. ^hk_ga` The amount of blocked damage. ]^okn^a` The amount of absorbed damage. _nepe_]h 1 if the hit was critical, nil otherwise. ch]j_ejc 1 if it was a glancing strike, nil otherwise. _nqodejc 1 if it was a crushing blow, nil otherwise. APPENDIX B N COMBAT LOG AND UNIT REFERENCE 457

Additional Arguments for the Suffix [DA=H All subevents that end in [DA=H receive the additional arguments listed in Table B-4.

Table B-4. Additional Arguments of Events with the Suffix [DA=H Argument Name Description ]ikqjp The amount of damage the attack did kranda]hejc The overheal _nepe_]h 1 if the hit was critical, nil otherwise

Additional Arguments for the Suffix [IEOOA@ All subevents that end in [IEOOA@ receive the additional arguments listed in Table B-5.

Table B-5. Additional Arguments of Events with the Suffix [IEOOA@ Argument Name Description ieooPula The reason the spell or attack missed ]ikqjp The amount of damage that missed

The ieooPula is one of the following strings:

ÊUÊ=>OKN> ÊUÊ>HK?G ÊUÊNABHA?P ÊUÊNAOEOP (]ikqjp is jeh if the whole spell was resisted) ÊUÊRQHJAN=>EHEPU (]ikqjp will be negative, as a vulnerability results in more damage dealt)

Additional Argument for the Suffix [B=EHA@ There is only one additional argument for failed spells or attacks: ieooPula. Don’t confuse this suffix with the suffix [IEOOA@ and its argument with the same name. A failed spell was not cast at all, for example because of insufficient mana. A missed spell or attack was cast but resisted or parried, for example. ieooPula is here already a localized string that is displayed as it is in your UI and not an identifier.

Additional Argument for the Suffix [ATPN=[=PP=?GO There is only one additional argument for actions that cause extra attacks: ]ikqjp, the num- ber of additional attacks granted. All of the extra attacks will generate the usual OSEJC[@=I=CA events. 458 APPENDIX B N COMBAT LOG AND UNIT REFERENCE

Additional Arguments for the Suffixes [AJANCEVA, [@N=EJ, and [HAA?D Subevents that end in [AJANCEVA, [@N=EJ, or [HAA?D receive the additional arguments listed in Table B-6.

Table B-6. Additional Arguments of Events with the Suffixes [AJANCEVA, [@N=EJ, and [HAA?D Argument Name Description ]ikqjp The amount of power gained. lksanPula The power type (mana, energy, health, and so on). atpn]=ikqjp Only available for [HAA?D. The additional power that was drained from the affected target but was not transferred to the caster (for example, when using Drain Life with full health).

The argument lksanPula is a number that identifies the power type. There are global variables available that should be used instead of the numeric identifiers as it makes your code more readable and resilient to API changes. Table B-7 lists all global variables with their respective values.

Table B-7. Possible Values for lksanPula Variable Value OLAHH[LKSAN[I=J= 0 OLAHH[LKSAN[N=CA 1 OLAHH[LKSAN[BK?QO 2 OLAHH[LKSAN[AJANCU 3 OLAHH[LKSAN[D=LLEJAOO 4 OLAHH[LKSAN[NQJAO 5 OLAHH[LKSAN[NQJE?[LKSAN 6

Additional Arguments for Dispels and Interrupts There are four events used when buffs are canceled prematurely: OLAHH[@EOLAH if it was dis- pelled, OLAHH[@EOLAH[B=EHA@ if a display attempt was resisted, OLAHH[OPKHAJ if a buff was stolen (for example by Steal Magic), and OLAHH[=QN=[>NKGAJ[OLAHH if a damage-sensitive debuff (like Polymorph) was broken by an attack on the target. The event OLAHH[EJPANNQLP is fired when a spell is interrupted; it uses the same argu- ments as the dispel events, so it’s listed here. Table B-8 lists the additional arguments of these events. APPENDIX B N COMBAT LOG AND UNIT REFERENCE 459

Table B-8. Additional Arguments of Dispel and Interrupt Events Argument Name Description atpn]OlahhE` The ID of the spell that was interrupted or dispelled. atpn]OlahhJ]ia The name of the interrupted/dispelled spell. atpn]O_dkkh The school (bit field) of the interrupted/dispelled spell. ]qn]Pula Only available for OLAHH[@EOLAH, OLAHH[=QN=[>NKGAJ[OLAHH, and OLAHH_OPKHAJ; this value is either >QBB or @A>QBB.

Additional Arguments for Buff Events There are six buff-related events:

 ¡OLAHH[=QN=[=LLHEA@  ¡OLAHH[=QN=[NAIKRA@  ¡OLAHH[=QN=[=LLHEA@[@KOA  ¡OLAHH[=QN=[NAIKRA@[@KOA  ¡OLAHH[=QN=[NABNAOD  ¡OLAHH[=QN=[>NKGAJ

All of them receive the additional argument ]qn]Pula, which is either >QBB or @A>QBB. The events ending with [@KOA also receive the argument ]ikqjp, which indicates the value of buff stacks on the affected unit after the event. Note that the event OLAHH[=QN=[>NKGAJ[OLAHH is, despite the name, a dispel event and uses different arguments.

Additional Arguments for Damage Shield Events There are three events related to damage shields: @=I=CA[ODEAH@ is fired when an attacker is damaged by the effect of a shield (such as Fire Shield). This event behaves like a OLAHH[@=I=CA event and receives the same arguments as such an event. @=I=CA[ODEAH@[IEOOA@ uses the same arguments as OLAHH[IEOOA@. Another shield type is one that splits the damage among multiple persons; it uses the event @=I=CA[OLHEP, which takes the same arguments as @=I=CA[ODEAH@.

Additional Arguments for Enchant Events Applying enchants or temporary effects like poisons or Shaman weapon buffs generates the event AJ?D=JP[=LLHEA@. The event AJ?D=JP[NAIKRA@ is fired when the effect wears off. Both events use the arguments listed in Table B-9. 460 APPENDIX B N COMBAT LOG AND UNIT REFERENCE

Table B-9. Additional Arguments of Events with the Prefix AJ?D=JP[ Argument Name Description olahhJ]ia The name of the spell or poison used epaiE` The ID of the targeted item epaiJ]ia The name of the targeted item

The Spell School Bit Field The default UI provides bit masks to extract flags from this bit field. Table B-10 shows all global variables that hold bit masks for spell bit fields.

Table B-10. Bit Masks for Spell Schools Variable Bit Mask O?DKKH[I=OG[JKJA 0x0 O?DKKH[I=OG[LDUOE?=H 0x1 O?DKKH[I=OG[DKHU 0x2 O?DKKH[I=OG[BENA 0x4 O?DKKH[I=OG[J=PQNA 0x8 O?DKKH[I=OG[BNKOP 0x10 O?DKKH[I=OG[OD=@KS 0x20 O?DKKH[I=OG[=N?=JA 0x40

The Unit Flags Bit Field Table B-11 shows the global variables that can be used as bit masks on the okqn_aBh]co and `aopBh]co arguments.

Table B-11. Bit Masks for Unit Flags Variable Bit Mask ?KI>=PHKC[K>FA?P[=BBEHE=PEKJ[IEJA 0x00000001 ?KI>=PHKC[K>FA?P[=BBEHE=PEKJ[L=NPU 0x00000002 ?KI>=PHKC[K>FA?P[=BBEHE=PEKJ[N=E@ 0x00000004 ?KI>=PHKC[K>FA?P[=BBEHE=PEKJ[KQPOE@AN 0x00000008 ?KI>=PHKC[K>FA?P[NA=?PEKJ[BNEAJ@HU 0x00000010 ?KI>=PHKC[K>FA?P[NA=?PEKJ[JAQPN=H 0x00000020 ?KI>=PHKC[K>FA?P[NA=?PEKJ[DKOPEHA 0x00000040 ?KI>=PHKC[K>FA?P[?KJPNKH[LH=UAN 0x00000100 ?KI>=PHKC[K>FA?P[?KJPNKH[JL? 0x00000200 ?KI>=PHKC[K>FA?P[PULA[LH=UAN 0x00000400 ?KI>=PHKC[K>FA?P[PULA[JL? 0x00000800 ?KI>=PHKC[K>FA?P[PULA[LAP 0x00001000 APPENDIX B N COMBAT LOG AND UNIT REFERENCE 461

Variable Bit Mask ?KI>=PHKC[K>FA?P[PULA[CQ=N@E=J 0x00002000 ?KI>=PHKC[K>FA?P[PULA[K>FA?P 0x00004000 ?KI>=PHKC[K>FA?P[P=NCAP 0x00010000 ?KI>=PHKC[K>FA?P[BK?QO 0x00020000 ?KI>=PHKC[K>FA?P[I=EJP=JG 0x00040000 ?KI>=PHKC[K>FA?P[I=EJ=OOEOP 0x00080000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP- 0x00100000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP. 0x00200000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP/ 0x00400000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP0 0x00800000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP1 0x01000000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP2 0x02000000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP3 0x04000000 ?KI>=PHKC[K>FA?P[N=E@P=NCAP4 0x08000000 ?KI>=PHKC[K>FA?P[JKJA 0x80000000

Unit IDs A unit ID is a string that identifies a player or NPC. What are called primary unit IDs that con- sist of single identifier (for example lh]uan); secondary (as well as tertiary, and so on) unit IDs can be built by appending suffixes to primary IDs. Table B-12 lists all primary unit IDs.

Table B-12. Primary Unit IDs Prefix Description bk_qo Your focus target. lh]uan You. lap Your pet. l]npuj The nth party member. Note that you are not your own party member, meaning that you cannot refer to yourself by using such a unit ID. 0 < n < 5. l]npulapj The pet of the nth party member. 0 < n < 5; you cannot refer to your own pet with this unit ID. n]e`j The nth raid member. This can, unlike l]npuj, be you. n]e`lapj The pet of the nth raid member. This can, unlike n]e`lapj, be you. ]naj]j The enemy players in arena matches. 0 < n < 6. p]ncap Your current target. ikqoakran The unit your mouse is currently over. jkja Refers to no unit. jl_ The NPC you are currently interacting with. Interacting means that you have a win- dow like the flight map or quest dialog of the NPC opened. 462 APPENDIX B N COMBAT LOG AND UNIT REFERENCE

The two suffixes p]ncap and lap can be appended to any unit ID to refer to the target or pet of a unit. Note that there is no difference between l]npulapj and l]npujlap when using the unit ID in a unit function like QjepJ]ia$qE`%. But l]npulapj is a primary unit ID, while l]npujlap is secondary. There are some events that are only fired for primary IDs; for example, QJEP[P=NCAP is fired every time a unit with a primary ID changes its target. You will therefore see the l]npulapj and n]e`lapj IDs as arguments in many QJEP[& events.

Unit Functions There are several functions available that retrieve information about the unit identified by a given unit ID:

ÊUÊQjep=bba_pejc?ki^]p$qE`%: Checks if the unit is in combat. ÊUÊQjep=nikn$qE`%: Returns the armor of the unit ID. This can only be used on yourself. ÊUÊQjep=pp]_g>kpdD]j`o$qE`%: Returns 1 if the unit wields two weapons. ÊUÊQjep=pp]_gLksan$qE`%: Returns the melee attack power. This can only be used on yourself. ÊUÊQjep=pp]_gOlaa`$qE`%: Returns the attack speed of the unit in seconds. ÊUÊQjep=qn]$qE`(^qbbE`(behpan%: Returns information about a specific buff on the unit. The first buff on a unit has the ID 1, the second 2, and so on. The third operational argument is a string that sets a filter. Possible values for the filter are the following:

ÊUÊ?=J?AH=>HA: Matches buffs that can be canceled. ÊUÊJKP[?=J?AH=>HA: Matches buffs that cannot be canceled. ÊUÊD=NIBQH: Matches spells that do harm. ÊUÊDAHLBQH: Matches helpful spells ÊUÊLH=UAN: Matches buffs cast by you. ÊUÊN=E@: Matches buffs that you can cast on other raid members. You can combine multiple filters in the filter string. The default value for behpan is DAHLBQH, meaning that it only returns buffs. For example, D=NIBQHLH=UAN matches all harmful spells that have been cast by you. The return values of this function are j]ia, n]jg, e_kj, _kqjp, `a^qbbPula, `qn]pekj, atlen]pekjPeia, qjep?]opan, and eoOpa]h]^ha. ÊUÊQjep?]j=ooeop$qE`-(qE`.%: Determines whether a unit can assist another unit. ÊUÊQjep?]j=pp]_g$qE`-(qE`.%: Determines whether a unit can attack another unit. ÊUÊQjep?]j?kklan]pa$qE`-(qE`.%: Determines whether two units can cooperate; that is, whether both units are players of the same faction. The difference between this func- tion and Qjep?]j=ooeop is that a player can assist an NPC but not cooperate with one. ÊUÊQjep?d]n]_panLkejpo$qE`%: Returns the number of unspent talent points of a unit. ÊUÊQjep?h]oo$qE`%: Returns the localized class of a player followed by the English name of the class in capital letters. APPENDIX B N COMBAT LOG AND UNIT REFERENCE 463

ÊUÊQjep?h]ooebe_]pekj$qE`%: Gets the classification of a unit; this can be jkni]h, pnere]h (“gray” mobs), ahepa, n]na, n]naahepa, or sknh`^koo. ÊUÊQjep?na]pqnaB]iehu$qE`%: Gets the creature family of a beast (for example, Cat or Spider). ÊUÊQjep?na]pqnaPula$qE`%: Gets the creature type of a unit (for example, Beast or Giant). ÊUÊQjep@abajoa$qE`%: Gets the defense skill of a unit. ÊUÊQjep@ap]eha`Pdna]pOepq]pekj$qE`-(qE`.%: Returns the threat situation between two units. The return values are eoP]jgejc, op]pqo, pdna]pl_p, n]spdna]pl_p, pdna]pr]hqa. ÊUÊQjepAteopo$qE`%: Determines whether a unit ID references an existing unit. ÊUÊQjepB]_pekjCnkql$qE`%: Returns the faction of a unit (for example, Sons of Hodir or Alliance). ÊUÊQjepCQE@$qE`%: Returns the GUID of a unit. ÊUÊQjepD]oNahe_Ohkp$qE`%: Determines whether a unit has a relic slot. ÊUÊQjepDa]hpd$qE`%: Returns the current health of a unit. ÊUÊQjepDa]hpdI]t$qE`%: Returns the maximum health of a unit. ÊUÊQjepEjL]npu$qE`%: Determines whether a unit is in your party. ÊUÊQjepEjN]e`$qE`%: Determines whether a unit is in your raid. ÊUÊQjepEjN]jca$qE`%: Returns 1 if qE` is less than 30 yards away from you. ÊUÊQjepEo=BG$qE`%: Determines whether a player is AFK. ÊUÊQjepEo?d]nia`$qE`%: Checks whether a unit is mind-controlled. ÊUÊQjepEo?kjja_pa`$qE`%: Checks whether a player is online. ÊUÊQjepEo?knloa$qE`%: Determines whether a unit is a corpse. ÊUÊQjepEo@a]`$qE`%: Determines whether a unit is dead. ÊUÊQjepEo@a]`KnCdkop$qE`%: Determines whether a unit is dead or in ghost forms. ÊUÊQjepEo@J@$qE`%: Checks whether a unit has DND enabled. ÊUÊQjepEoAjaiu$qE`-(qE`.%: Checks whether two units can attack each other. ÊUÊQjepEoBaecj@a]pd$qE`%: Determines whether a unit is feigning death. This only works on units in your party or raid. ÊUÊQjepEoBneaj`$qE`-(qE`.%: Returns 1 if two units are friendly towards each other. ÊUÊQjepEoCdkop$qE`%: Checks whether a unit is in ghost form. ÊUÊQjepEoLRL$qE`%: Checks whether a unit is flagged for PvP. ÊUÊQjepEoLRLBnaaBkn=hh$qE`%: Checks whether a unit is flagged for FFA PvP (for example in the Stranglethorn Arena). ÊUÊQjepEoL]npuHa]`an$qE`%: Determines whether a unit is the leader of a party. ÊUÊQjepEoLh]uan$qE`%: Determines whether a unit is a player. 464 APPENDIX B N COMBAT LOG AND UNIT REFERENCE

ÊUÊQjepEoLhqoIk^$qE`%: Returns 1 for elite mobs. ÊUÊQjepEoP]lla`$qE`%: Checks whether a mob is tapped by someone else. ÊUÊQjepEoP]lla`>uLh]uan$qE`%: Checks whether a mob is tapped by you. ÊUÊQjepEoPnere]h$qE`%: Checks whether a mob is trivial (“gray”). ÊUÊQjepEoQjep$qE`-(qE`.%: Checks whether two unit IDs reference the same unit. ÊUÊQjepEoReoe^ha$qE`-%: Checks whether a unit is in your range (about 100 yards). ÊUÊQjepHarah$qE`%: Gets the level of a unit. ÊUÊQjepJ]ia$qE`%: Returns the name and server (in battlegrounds) of a player. ÊUÊQjepKjP]te$qE`%: Checks whether a unit is on a taxi service. ÊUÊQjepLh]uan?kjpnkhha`$qE`%: Checks whether a unit is controlled by a player. ÊUÊQjepLh]uanKnLapEjL]npu$qE`%: Determines whether the unit is a member of your party or a pet of a party member. ÊUÊQjepLh]uanKnLapEjN]e`$qE`%: Works like QjepLh]uanKnLapEjL]npu but for raid groups. ÊUÊQjepLksan$qE`(lksanPula%: Gets the current amount of lksanPula (mana, energy, and so on) of a unit. lksanPula uses the same values as mentioned in the combat log arajp above. ÊUÊQjepLksanI]t$qE`(lksanPula%: Gets the maximum amount of lksanPula of a unit. ÊUÊQjepLksanPula$qE`%: Gets the current power type of a unit. ÊUÊQjepN]_a$qE`%: Gets the localized race of a unit followed by a non-localized capitalized string. ÊUÊQjepN]jca`=pp]_gLksan$qE`%: Returns the ranged attack power. This only works on yourself. ÊUÊQjepNa]_pekj$qE`-(qE`.%: Determines the reaction of qE`- towards qE`.. Possible val- ues are bneaj`hu, jaqpn]h, and dkopeha. ÊUÊQjepTL$qE`%: Gets the current XP of qE`-. This only works on yourself. ÊUÊQjepTLI]t$qE`%: Gets the maximum XP of qE`-. This only works on yourself. Index

Numbers and Symbols access control list (ACL), 82 3D application Ace3 framework, 283–295 creating simple, 400–402 advanced Hello, World with, 286 creating the sky in, 402 first steps with, 285–286 creating trees, 401 simple Hello, World addon with, 283–284 \36 (ASCII code for $), 395 web site address for information about, \124, Lua escape code, 259 283 255-character limit, circumventing in mac- Ace3 libraries, embedding, 284 ros, 354–355 AceAddon-3.0 object, OnInitialize method : (colon) operator, 62, 172 of, 287 -- (double hyphens), designating comments AceAddon object, 290 with, 16 AceConfig-3.0 == (equality test operator), 27 configuration with, 290–295 == (equality operator), 15 web site address for documentation, 295 = (equality sign), assigning a value to a vari- AceConfig frame, automatically generated, able with, 17 293 % (modulo operator), used in FindNextPosi- AceConfig table, creating for Hello, World tion method, 217 mod, 292–293 ~= (negation of the equality test) operator, 27 AceConsole, / commands with, 286 | (pipe symbol), as escape character, 258 AceDB-3.0, 286 / (slash) commands, creating, 63–65 creating new with default values, 287–288 [] (square brackets), using in strings, 19–20 data types, 288–289 || (two pipe symbols), representing normal saved variables with, 287–289 pipe symbol, 259 AceDB-3.0 API documentation, web site ad- /ahwgui, creating, 294 dress, 288 /channel command, creating, AceOptions table, 290 292–293 advanced with groups, 290–292 /cm gui command, creating, 305 available option types for, 295 /cooldownmonitor gui slash command, 308 building / commands from, 293–295 /script command, creating one-minute timer code for, 291 with, 301 simple, 290 / (slash) commands, creating, 63–65 AceOption tables, building GUIs from, 293 Ace project, web site address, 5 acl add and acl remove commands, 87 A AddCommunityCard method, 216, 240 AddDoubleLine method, 298 , 99 addHighest(n, ...) function, writing, 206 absorbed argument, for events with DAM- AGE suffix, 243 AddMessage method ACCEPT global variable, 135 of chat frame object, 259 __add metamethod, 170 465 466 NINDEX

addon communications ENVIRONMENTAL_ prefix, 456 basics of, 228–230 _EXTRA_ATTACKS suffix, 457 building poker game client with, 227–240 _FAILED suffix, 457 example of concatenation in Lua, 367–370 _LEECH suffix, 458 ADDON LOADED event, calling Poker_ in Lua, 15 TableBrowser.ADDON_LOADED of events with _DAMAGE suffix, 456–457 function, 224 of events with _HEAL suffix, 457 addon messages of events with _MISSED suffix, 457 function for sending test, 229 prefixes SPELL_ and RANGE_, 456 playing around with, 229–230 standard for combat log events, 455–456 receiving, 229 arithmetic expressions. See arithmetic opera- security and, 230–232 tors sending, 228 arithmetic operators, 26–27 addons arrays available message channels, 228 created by using tables, 160–161 displaying chat time stamp using a hook, understanding, 374–377 158 what they look like internally, 374–375 naming, 228 array size, in Lua, 375–377 profiling in WoW, 363–364 ARTWORK layer, creating template for en- that make use of graphs, 165 tries with, 116–118 AddOn Studio IDE, 9 Assignments, in Lua, 37–38 AddText method, 289 associated array, 377 adjacency matrix, 166 associative array, 23 amount argument, for events with DAMAGE attackingUnit prototype, 177 suffix, 243 Attack(target) method, 173 anchor, function of, 99–100 attributes ANCHOR_CURSOR, using, 74 building unit frames with, 326–331 element, 99 in XML elements, 94 AND binary operator of header templates, 331–333 for reading a specific bit, 249 playing around with for secure action but- truth table of, 249 ton, 336–338 and operator, 28, 29 vs. methods, 173 announces and warnings, 313–314 auctions anonymous functions, in Lua, 22 canceling, 89–90 API functions, provided by World of Warcraft, ending, 84–86 58 placing bids, 86–87 Apress web site address, for book source remote control of, 90–91 code download, 11 starting, 83–84 args field, needed by group type, 290 argument option, string.format function, 52 arguments buff events, 459 B DAMAGE SHIELD events, 459 element, adding to DISPELS and INTERRUPTS, 458–459 element, 103 _DRAIN suffix, 458 Backdrops, adding to frames, 102–103 ENCHANT events, 459 element, in element, 102 _ENERGIZE suffix, 458 NINDEX 467 bar:SetText(text) method, 302 Blizzard XML files, checking for templates, bar object, 302 109 Battle and Defensive Stance, with Shield blocked argument, for events with DAMAGE Bash, 352 suffix, 243 Berserker Stance, use of Pummel in, 352 blocks, creating using do end blocks, 40 betting rounds, starting, 213–214 boolean value, in Lua, 21 bettingRoundStarted state, 210 border, creating around buttons, 111–112 bgFile attribute, in element, 102 boss mods. See also Deadly Boss Mods bids, placing, 86–87 calling constructor in, 311 big O notation, convention used in book, creating new, 311–312 364–366 localizing, 314 binary OR operator, truth table of, 250 break statement, 36 binary search algorithm, 365 BroadcastMessage method, called in Move- binary XOR operator, 251–252 DealerButton method, 217 bindings, in Lua, 1 btn or mod condition, 352 binSearch function, 365 bubble sort algorithm, 366 bit.band function, 249 buff events, arguments for, 459 bit.bnot(bitfield) function, 251 bug, fixing for World Map, 273–274 bit.bor, checking for multiple spell schools buildGuidTable function, code showing, 247 with, 254 buttons bit fields, 248–252 adding text to new, 130 limits of in Lua with bitlib, 252 creating, 118–121 vs. booleans, 252 creating from a template, 114–115 bitlib, 190-191 creating more, 128–130 functions in, 190 defining in XML, 107 web site for downloading, 190 filling, 120–121 bit library, 190–191. See also bitlib in XML, 107–108 loading for testing in Lua interpreter, 249 simple, 110–111 bit.lshift(bitfield, n) function, creating a bit static popup dialogs and, 128–135 mask with, 250 button template, using, 108–109 bit masks Button type, 424–428 categories of, 255 Lua methods, 425–428 creating, 249–250 script handlers, 428 for spell and damage schools, 252–253 XML attributes, 424 for unit flags, 254–255 XML elements, 424–425 bits element, defining text of but- reading, 249–250 ton with, 108 resetting, 251 setting, 250–251 toggling, 251–252 C bitwise operations, how they work, 249–250 CaduneTreeParameters object, trees created bitwise OR operator, for setting bits, 250–251 from, 401 CANCEL global variable, 135 useful programs, tools, and web sites, 4 Cancel method, for canceling timers, 271–272 World of Warcraft published by, 2 Cancel or Close buttons, creating, 145 Captures, example using two, 50 468 NINDEX

cards CHAT_MSG_WHISPER event, demonstrating additions to localization file, 196 event handler with, 75 calculating a rating of a hand, 200–202 chat time stamps, addon that displays using code loop that generates all 52 cards, 196 a hook, 158 creating, 196–197 check boxes. See check buttons drawing in game, 216 checkButton, GetChecked() method, 146 extracting and rating the best hands, check buttons, for setting permissions, 199–200 143–144 fields in table, 196 CheckButton type, 428–429 function comparing values of two cards, Lua methods, 429 199 XML attributes, 428 getting, 197–198 XML elements, 428 loop for testing correct creation of, 197 CheckFlagCarrier method, 335 shuffling and drawing, 215–216 Child, of frame, 98 cardsByRank table, creating, 196 Chunk, in Lua, 57 card type scores, 201 clampedToScreen="true" attribute, 106 caster’s flags, 257 class and prototype, interchangable use of, CastingBarFrameTemplate, defined by Inter- 175 face\FrameXML\CastingbarFrame. class data type, 288 xml, 263 closing tag, of XML element, 94 cast sequence command, 344–345 closures, in Lua, 152–154 CastSpellByName(“name”) function, 319 collectgarbage(), testing garbage collector Celes, Waldemar, Lua developed by, 1 with, 188–189 |c escape-sequence, 259 collectgarbage(option) function, memory channel argument, 228 usage returned by, 362 character classes, examples of usage, 49–50 collectgarbage(option, value) function, con- characters, with special meaning in Lua, 50 trolling garbage collector with, 188 char data type, 288 collision, in hash table, 378 ChatFrame1.AddMessage function, 158 color code, format of, 259 chat frames colored texts, 259–260 and their script handlers, 71–72 color option type, 295 determining default, 259 color reset code, 259 storage of default, 71 ColorSelect type using escape sequences in, 258–263 Lua methods, 430–431 ChatlinkTooltips script handlers, 431 creating, 71–74 XML attributes, 430 module in action, 69 combat log, and unit references, 455–464 chat messages COMBAT LOG EVENT, 455 hiding, 91–92 working with, 241–244 sending, 355–356 combat log events, 455–461 CHAT_MSG_ADDON standard arguments, 455–456 complete event handler, 231 COMBAT LOG EVENTS, working with, 241–244 event arguments, 229 COMBAT LOG EVENT UNFILTERED, 455 event handler for, 231 working with, 241–244 CHAT_MSG_ADDON event, registering, 235 COMBATLOG_OBJECT_RAIDTARGET_ CHAT_MSG_GUILD, 75 MASK variable, 255 CHAT_MSG_RAID, 75 NINDEX 469

COMBATLOG_OBJECT_REACTION_ CooldownMonitor_Anchor frame, 267 HOSTILE mask, 255 CooldownMonitor.lua file COMBATLOG_OBJECT_TYPE_PLAYER mask, adding code for status bar timer construc- 255 tor to, 268–269 combat logs, creating, 244 building, 256–274 commands, available for macros, 340–346 creating print local variable in, 260 comments, in XML, 94 detecting spells, 256–258 community cards, 239–240 CooldownMonitor.StartTimer function, cre- and player cards, 216 ating, 263, 269–270 compile-time errors, 181 CooldownMonitor.Unlock function, Show- concatenation MovableBar called by, 303 example in addon communication, CooldownMonitor.xml file 367–370 adding frame to, 267 graph of memory usage, 369 code for template, 264–265 of strings in Lua, 20 Cooldown type, 429–430 vs. table.concat function performance, 370 Lua methods, 429 conditions XML attributes, 429 adding to macros, 346–353 Core.lua file, creating real addon code in, available for all secure commands, 284–286 346–348 coroutine.create(func) function, 391 combining to build complex expressions, coroutine library, in Lua, 390–392 349–351 coroutine.resume(co, ...) function, 391 conflicts, resolving in hash tables, 378 coroutine.running() function, 391 control structures, 29 coroutines in Lua, 33–37 available functions that work with, 391 simple, 351–352 creating example of, 391–392 conventions, used in examples, 364–366 coroutine.status(co) function, 391 CooldownBars.lua coroutine.wrap(func) function, 391 adding Lua functions to, 266 coroutine.yield(...) function, 391 building new and improved, 301 CPU profiling, in WoW, 363–364 file, 263 CPU time, measuring amount used by Lua CooldownBarTemplate, children of, 265 scripts, 362 CooldownMonitor CreateBar, arguments when creating a bar, adding options to, 304–308 302 adding wrapper functions to main file, 300 createCounter function, 152–153 basic options, 305 CreateFlagCarrierButton method, called building, 256–274 when Warsong Gulch is joined, creating folder and TOC file for, 256 334–335 creating XML and Lua files for, 256 CreateFrame function, 70 improving with Deadly Bar Timers (DBT), creating timers from template with, 265 299–308 createGetter function, 307 integrating Deadly Bar Timers (DBT) in, CreateMonster function, 174 302–303 createSetter function, 307 option to show test bars, 305 CreateVector(x, y, z) function, 170 option to unlock and move bars, 305 critical argument, for events with DAMAGE placing functions in to be accessed from suffix, 243 outside the table, 258 crushing argument, for events with DAMAGE using Combat Log to build, 241–274 suffix, 243 470 NINDEX

currentPlayer attribute, 214 DeadlyBossMods.com, 5 Curse, web site address, 5 Deadly Boss Mods’ module, 61–62 Curse.com, free Subversion repositories for dealer button, moving, 216–217 addons from, 400 debug library, function available in World of custom timer, creating, 232 Warcraft, 54 cvar (console variable), tuning options with, debugstack() function, 182 358 debug.traceback() function, 182 cyclic lists, in Lua, 165 Decursive addon, 2 cyclic references, 155 deep copy function, 156 DEFAULT_CHAT_FRAME global variable, 71 default chat frame held in, 259 D default UI digging through, 130–131 DAMAGE SHIELD events arguments for, 459 extracting, 66–67 DAMAGE suffix, arguments of events with, 242–243 defaultValue attribute, for sliders, 141 _DAMAGE suffix, arguments of events with, de Figueiredo, Luiz Henrique, Lua developed 456–457 by, 1 data structures delete(list, node) function, using in doubly linked lists, 164 in Lua, 22 De Morgan’s Law, 349 object orientation and, 180–181 desc field, in AceOptions table, 290 using another, 222 description option type, 295 using tables to build, 160–168 destFlags argument, combat log events, 242 data types destGUID argument, combat log events, 242 basic in Lua, 17–26 destName argument, combat log events, 242 provided by AceDB-3.0, 288 DevTools, event trace , 5 DBM. See Deadly Boss Mods Dialogs, static popup, 130–135 DBM-Core addon, 299 DIALOG strata, frameStrata attribute, 104 DBT. See Deadly Bar Timers (DBT) element, setting font used DBT options, 305–308 for different states with, 108 setting, 304 disjunctive normal form, transforming ex- Deadly Bar Timers (DBT) pressions into, 350–351 first steps with, 301–302 DISPELS and INTERRUPTS, arguments for, improving CooldownMonitor with, 458–459 299–308 distributive law, 350 integrating in CooldownMonitor, 302–303 DKP auctioneer mod playing around with, 301 local functions and their scope, 82 Deadly Boss Mods, 309–317 starting auctions, 83–84 documentation web site addresses, 305, using timing library for, 81–92 308 variables and options, 81–82 forum web site address, 300 DKP / commands, creating simple, 87–89 history of, 309–310 do-end block, 83 localizing, 314 do...end block, 157 real-world examples from, 50–51 dofile("localization.en.lua"), 195 TOC files, 310–311 do keyword, 38 UNIT DIED handler, 246 double hyphens (--), designating comments web site address, 275, 300 with, 16 NINDEX 471 doubly linked lists ENVIRONMENTAL events, 242 creating in Lua, 162–163 ENVIRONMENTAL_ prefix, argument for, in Lua, 161–165 456 _DRAIN suffix, arguments for, 458 environmentalType argument, 242 DressUpModel type, 444 __eq metamethod, 170 Druid healing spell, macro that casts, 342 equality operator (==), 15 dummy entries, creating for testing, 126–127 equality sign (=), assigning a value to a vari- dummy function, adding one that prints a able with, 17 message to chat, 123 equality test operator (==), 27 dynamic typing, in Lua, 25–26 equipped condition, use of, 348 error messages creating custom, 182–183 suppressing in macros, 357–358 E error(msg, level) function, 183 edgeFile attribute, in element, errors 102 catching and handling, 181–183 element, in element, handling in Lua, 181–187 102 escape sequences editBox:GetText() method, 146 provided by Lua, 20 edit boxes using in chat frames, 258–263 creating simple, 138–139 event argument, textures and font strings for, 139–140 combat log events, 242 EditBoxOnEnterPressed event handler, 134 CHAT_MSG_ADDON, 229 EditBox type, 431–435 event handlers, 69. See also script handlers Lua methods, 432–435 basics of, 75 script handlers, 435 building, 243–244 XML attributes, 432 creating a function that acts as, 395–396 editor:AddText(text) method, using, 394 fake events for in Lua, 368–369 elements for multiple events, 75–77 adding to another element, 101 in Warhammer Online, 398–399 in XML terminology, 94 simple in Lua, 367–368 selecting in the list, 122–123 that do all necessary checks, 235–236 elseif-block, condition used by, 352 event list, web site address, 398 embedded libraries event listeners, using frames as, 70–71 creating your own, 279–283 events, working with, 312–313 problems with, 277 event trace window, DevTools, 5 using in World of Warcraft, 275–276 execute type, 295 embeds.xml file, creating, 284, 304 in AceOptions table, 290 ENCHANT events, arguments for, 459 execution path, 319 endAuction function, writing, 84–86 exercise, templates, 138 EndCombat method, called on all boss mods, 246 exit actions, defined by states, 211 end keyword, 15, 38 ExpandUpwards option, function to set, 307 _ENERGIZE suffix, arguments for, 458 expressions, 26–31 entry actions, defined by states, 211 tables and functions as, 30 environment external Lua files and XML files, including, 95–96 global variables contained in, 184–187 _EXTRA_ATTACKS suffix, argument for, 457 modifying, 185–186 472 NINDEX

F frame:SetPoint(point, relativeTo, relative- faction data type, 288 Point, x, y) method, creating a new factionrealm data type, 288 anchor with, 100 _FAILED suffix, argument for, 457 frame:SetWidth(width) method, 102 fake events, for event handler in Lua, 368–369 frames Far Cry, Lua used by, 1 adding capability to display to our Lua file, 136 FauxScrollFrame_OnVerticalScroll, calling, 124 basics of, 98–106 FauxScrollFrame_Update, calling, 125–126 children of, 98 files, restarts and editing existing, 63 creating in World of Warcraft, 95–95 filterIncoming function, 91 creating normal for new poker mod, 135 filterOutgoing function, 91 for adding a secure hook to event handler, 322 filters, combining multiple in filter string, 462 movable, 106 finalizer metamethod, 387 overview of XML file, 146–148 findHighCard(cards) function, 208 restrictions on protected, 324–325 FindNextPosition method, 217 retrieving name of, 95 findPair(cards) function, testing, 207 saving frame position with, 106 finite-state machines (FSM), 210–211 using as event listeners, 70–71 designing poker game servers as, 209 using Lua to create, 118–119 diagram showing all states as bubbles, 210 using, 74 FlagCarrier variable, 335 frame size Flash Heal (Rank 11) spell, adding for testing, 257 retrieving, 102 flyable bug, circumventing, 358–359 setting, 101 folder structure, for WoW addons, 58–59 frame strata, 103–104 element, 105–106 setting from Lua, 104 , adding for text boxes, frameStrata attribute 140–140 of a frame, 103–104 FontString type, Lua methods, 421–422 valid values for, 103 Font type frames XML file, overview of, 146–148 inherits from Object type, 407–409 Frame type, 412 Lua methods, 408–409 Lua methods, 414–420 XML attributes, 407 script handlers, 420–421 XML elements, 407–408 XML attributes, 412–413 for-loop, 16, 34–36 XML elements, 413–414 more about generic, 159–160 frame type button, 107 frame:ClearAllPoints() method, calling to frame types delete all points, 101 creating more with options, 135–146 element creating in World of Warcraft, 405–454 adding code to to create button, 109 FrameXML\Fonts.xml, finding all available adding layers to, 104–105 font objects in, 105 in root element, 95 FrameXML\ChatFrame.lua file, 320 frame:GetPoint(n) method, 100 FrameXML_Debug function, 97 frame:IsProtected() method, 325 FuBar plugin frame:RegisterForDrag(button) method, 106 adding tooltip to, 298 frame:SetHeight(height) method, 102 creating, 295–299 frame:SetHook, 322 web site for downloading, 296 NINDEX 473 func field, in AceOptions table, 290 GetNextPlayer method, 214 function GetNumRaidMembers() function, used by in Lua, 14 buildGuidTable function, 247 that calculates factorial of a number, 15–16 GetPlayerMapPosition(unitId) function, 298 function calls, 31–33 GetRealZoneText() function, 298 functions, restricted, 320–321 GetSpellInfo function, arguments for, 262 function value, in Lua, 21–22 getter function, stored in get, 292 GetTime() function, 78 GetType() method, 176 glancing argument, for events with DAMAGE G suffix, 243 game announcements global cooldown, spells that don’t activate, receiving, 235–237 342 sending, 233–235 global data type, 288 game events, working with, 69–92 global environment, 184–185 games, joining, 211–213, 237–239 global variables GameTooltip global variable, 298 _G, 184 185 GameTooltip method speed of, 373 Lua methods, 436–437 vs. local variables, 372–373 setting tooltip content, 437–439 grammatical escape sequences, 262–263 garbage collector, 187–190 graphs, 165–168 checking for weak references, 188 five nodes connected via 10 edges, 166 controlling, 188 group header templates, using, 331–333 incremental garbage collection, 188 group type, 290, 295 Lua 5.0, 187 GUIDs, examples, 246–247 option arguments, 188 GUIDs and units, working with, 244–248 testing, 188–190 GUILD channel, messages from, 231 __gc finalizer metamethod, in Lua, 390 generic for loops, 159–160 GetAddOnCPUUsage(addon) function, 363 GetAddOnMemoryUsage(addon) function, H 364 hand GetAlpha() method, 63 calculating rating of, 200–202 GetAttribute(attribute), retrieving current finding and rating, 202–208 value of attribute with, 326 finding pairs, 204–205 GetCard function, 198 finding straights, 202–204 GetEventCPUUsage(event) function, 364 handler field, of option table, 290 getfenv(func or level) function, 185 hash code, of object, 378 GetFrameCPUUsage(frame, includeChil- hash function, 378 dren) function, 364 hash tables GetFunctionCPUUsage(func, includeSubs) basics of, 377–378 function, 363 collision in, 378 getglobal(name) function, provided by World creating in Lua, 378–381 of Warcraft, 184 resolving conflicts in, 378 getMax(...) function, writing, 206–207 testing in Lua, 381–382, 390 getmetatable, calling on a frame, 172 understanding, 377–382 getmetatable(table) function, 169 using in Lua, 23 474 NINDEX

head, doubly linked lists, 161 if-else-elseif block, available in a macro, headers, creating a template for, 112–113 351–352 header templates, attributes of, 331–333 if/else control structure, 15 header type, 295 if statements, 33 Healing Wave, macro that casts, 342 working with local variables in, 39 _HEAL suffix, arguments of events with, 457 writing alternative to, 39 HelloAce.toc, creating, 283–284 if-then-else-end construct, 28 Hello, World inactive attribute, in OnPlayerJoin method, in Warhammer Online, 396–399 212 with SciTE, 394–395 inCombat variable, mods stored in, 246 Hello, World mod /in command, using in macros, 357 creating AceConfig table for, 292–293 element, including another XML with DBT, 301–302 file with, 95 HelloWorld, 289 index, providing to read value from a table, 22 folder, creating in Interface/AddOns folder, 58 __index metamethod, 181 function, creating with SciTE, 394 and constructors, 172 HelloWorld Initialize function, creating in inheritance Lua file, 398 from a template, 107 HelloWorld.lua file, creating, 397–398 in Lua, 175–177 HelloWorld.mod file, creating, 397 multiple, 177–180 HelloWorld OnChat function, creating, inherits attribute, 105 398–399 inline functions, 32 HelloWorld.toc file, creating, 59–60 input action, 211 hidden attribute, 118 input option type, 295 Hide method, calling on a tooltip, 74 insertAfter(list, node, data) function, in dou- high cards, finding, 208 bly linked lists, 163 higher-order functions, in Lua, 152 insertAtEnd function, in doubly linked lists, HIGHLIGHT level, 105 164 element, setting font for dif- insertAtStart(list, data) function, in doubly ferent states with, 108 linked lists, 164 hooking, in Lua, 157–158 insertBefore function, in doubly linked lists, 164 hooking secure functions, 321–322 Interface AddOn Kit, web site address, 7 hooksecurefunc(tbl, key, hook) function, 321–322 interface API function, 62 Howling Fjord, graph in, 168 Interface\FrameXML\CastingbarFrame.xml, CastingBarFrameTemplate defined Hyperlinks, escape sequence for creating, by, 263 260–261 Interface/FrameXML/FriendsFrame.xml, 130–131 Interface/FrameXML/UIPanelTemplates. I xml, 109 IconLeft option, 305 inventory IDs, types of, 345 IconRight option, 305 issecurevariable(tbl, key) function, 321 Identifiers, examples of valid, 17–17 IsSelected function, 122 IDEs (integrated development environ- updating return statement in, 128 ments), 8–11 IsVisible method, using to fix bug for World Ierusalimschy, Roberto, Lua developed by, 1 Map, 273–274 NINDEX 475 item IDs, 73 problems with embedded, 277 item links, 72–73 problems with overwriting old versions, item slot IDs, 345–346 281–282 iterator, when and how it is called, 159–160 using, 275–317 versioning, 276–277 LibStub downloading latest version of, 277 J embedding, 280 Java, web site address, 97 functions accessible by addons and librar- join requests ies, 277–278 receiving responses, 238–239 source code, 278–279 sending, 237–238 using, 277–279 JoinTable method, setting curHost and call- list element, building, 111–128 ing SendMessage, 237 list entries, creating template for, 116–118 justifyH attribute, 118 lists scroll frames for, 123–128 selecting elements in, 122–123 K sorting, 121–122 keybinding option type, 295 LoadOptions (id) method, 303 key/value pairs, hash table entries as, 377 loadstring, 282 local functions, defining, 40–41 local variables L creating, 38–41 example of, 38–39 Layers, in a frame, 104–105 vs. global variables, 372–373 element localization file, adding lines to, 115 adding for creating a title for our frame, localizations, adding more languages, 317 137 localized variables, accessing, 316 as container for all layers, 105 logical AND, 349 valid values for level attribute of, 105 logical NOT, 349–350 layers and textures, 103–106 logical operators, 28–29 _LEECH suffix, arguments for, 458 logical OR, combining two conditions with, length operator #, 21 350–351 _len userdate metamethod, 389 Lua level attribute, valid values for, 105 advanced, 151–193 lexical (static) scoping, used by Lua, 152 advantage of for creating frames, 93 LibFuBarPlugin-3.0 advantages of, 1 embedding, 296–297 and Lugre, 399–402 for writing a FuBar plug-in, 296 available metamethods provided by, 171 using, 297–299 basics of, 13–16, 55 web site address for downloading, 296 by Roberto Ierusalimschy, et. al., 1 WowAce.com for documentation, 299 creating named frames in, 95 libraries developed at Pontifical Catholic Univer- building a skeleton addon for, 279–280 sity, 1 creating our own embedded, 279–282 expressions in, 26–31 embedded in WoW, 275–276 in Warhammer Online, 396–399 Lua standard, 43–55 just-in-time compiler, 2 476 NINDEX

language written in, 2 Lua.org/Lua-users.org, 5 measuring CPU time used by a script, 362 Lugre measuring memory usage in, 362 Lua and, 399–402 measuring performance in, 362–366 Lua binding for OGRE 3D, 393 more about functions in, 151–158 Main function called by, 400 other uses for, 393–403 setting up, 400 setting frame size in, 102 web site address, 399 setting the strata from, 104 web site address, 402 simple event handler in, 367–368 speed of, 2 strings in, 367–371 M table.concat(tbl, delimiter) function in, macro feedback, 353 370 macros tips, tricks, and optimization, 361–392 adding conditions to, 346–353 using, 13–14 available commands for, 340–346 using in macros, 355–359 circumventing 255-character limit in, variables and data types, 16–26 354–355 web site address, 2 for interrupting spells, 352 web site for apps and games that use, 393 in Lua, 339–360 web site for libraries and bindings, 403 inserting healing spell of class to use, 341 Lua code, executing in-game, 62 suppressing error messages in, 357–358 LuaEdit IDE, 8 that incorporate a logical OR in expres- LuaForge, bitlib project page, 190 sions, 350–351 Lua libraries, more about, 190–192 timers in, 356–357 Lua methods tuning options, 358 Button type, 425–428 ultimate for lazy healers, 351 CheckButton type, 429 using Lua in, 355–359 ColorSelect type, 430–431 Main function, called by Lugre, 400 Cooldown type, 429 math.cos function, example that calls, 373 DressUpModel type, 444 math library, functions available in, 43–45 EditBox type, 432–435 math.random, 215 FontString type, 421–422 math.randomseed, in Lua, 215 Font type, 408–409 math.sin function, example that calls, 373 Frame type, 414–420 max field, 291 GameTooltip method, 436–437 maxValue attribute, for sliders, 141 MessageFrame method, 440 memory profiling, in WoW, 364 Model type, 441–443 memory usage Object type, 406–407 if something goes wrong, 369–370 PlayerModel type, 443–444 measuring in Lua, 362 Region type, 410–412 merge sort, sorting algorithm, 366 ScrollFrame type, 445–446 MessageFrame method, 439–440 ScrollMessageFrame type, 447–448 messages SimpleHTML type, 449–450 receiving addon, 229 Slider type, 451–452 sending addon, 228 StatusBar type, 453–454 message types, needed in poker addon, 233 TabardModel type, 444–445 metamethods, and metatables, 169–171 Texture type, 423–424 NINDEX 477 metatables multiple inheritance, 107 adding to all tables in a given table, in Lua, 177–180 224–225 multiselect option type, 295 attaching to a saved table, 224–225 MyMod.SPELL_CAST_START function, up- and metamethods, 169–171 dating, 255 basic functions used when working with, 169 overloading operators, 169–170 N metatables and variables, saved, 222–225 \n, embedding new line characters with, 20 methods vs. attributes, 173 name field, in AceOptions table, 290 min field, 291 namespaces, in Lua, 186–187 minValue attribute, for sliders, 141 nearest neighbor algorithm, 167–168 MISSED suffix, arguments of events with, 458–459 .NET Framework (LuaInterface), 1 _MISSED suffix, arguments of events with, NewAddon method, 285 457 _newindex method, in Lua, 379 missTYPE argument, 457 NewLibrary method, 278 mixins, 285 newList function, 163 Model type NewPlayer commands, 239 Lua methods, 441–443 newproxy() function, 392 XML attributes, 441 nextNode function, using in doubly linked XML elements, 441 lists, 164 .mod file nil type, 18 event handlers available, 398–399 nodes, in doubly linked lists, 161 in Warhammer Online, 397 normal slash commands, 340 modulo operator (%), used in FindNextPosi- web site for Blizzard list of available, 340 tion method, 217 element, setting font used for monster prototype, creating, 177–179 different states with, 108 monsterPrototype table, creating, 172–175 not operator, 28 /mount command, code for creating, 359 NPC and vehicle GUIDs, 245 mouse click, function to fake, 331 numbers, operators for, 26 mouse wheel, scrolling with, 127 number type, 18–19 movable attribute, making a frame movable NUM_CHAT_WINDOWS global variable, 71 with, 106 movable frames, 106 move command, for moving timers, 272 O MoveDealerButton method object-oreinted programming, using in Lua, to determine next active player, 216 171–172 using FindNextPosition method, 216–217 object orientation MPQ archives, used by Blizzard games, 58–59 and data structures, 180–181 MPQ Editor in Lua, 171–181 browsing MPQ archives with, 66 object-oriented API, basics of, 62–63 web site address, 7 object-oriented timing library, 220–221 MPQ viewer, browsing MPQ archives with, 66 Object type, 405–407 msg argument, 228 Font type inherits from, 407–409 MSV, validating an XML opened in SciTE, 96 Lua methods, 406–407 __mul metamethod, 170 XML attributes, 405–406 478 NINDEX

OGRE 3D, Pro OGRE 3D Programming about, OnValueChanged handler 399 adding variables used in, 143 OGRE 3D project, web site address, 402 arguments for, 141 OGRE (Lugre), 3D engine from Lua, 1 for sliders, 141 OK/Create button, creating, 145–146 OnVerticalScroll script handler, invoking, 124 OnBeforeSave handler, 395–396 opening tag, of XML element, 94 OnClick handler, code behind, 330–331 Open method, of library AceConfigDia- OnDisable method, 285 log-3.0, 293 OnDragEnd script handler, 106 operating system library (os), 54–55 OnDragStart script handler, 106 operator precedence, examples of, 30 adding to element, 273 operators, overloading, 169–170 One-Hand condition, 348 optimization, main rules of, 366 OnEnable method, 285 optimizing, SimpleTimingLib, 383–387 OnEvent script handler, 95, 74–77 OptionalDeps field, for embedded libraries, OnHide script handler, stopping the anchor 280 with, 273 OptionalDeps TOC attribute, 297 OnHyperLinkEnter script handler, 71–72 Options, tuning, 358 OnHyperLinkLeave script handler, 71–72 OptionsCheckButtonTemplate, for creating OnInitialize, using Print method in, 285 check buttons, 143–144 OnInitialize handler, testing, 398 OptionsSliderTemplate, using, 141 OnLoad script handler, 95, 328 or operator, 28. See also bitwise OR operator adding line to to save frame position, 106 os.clock() function, measuring CPU time adding variables used in, 143 used by a script with, 362 needed to initialize frame, 327 os.date, available format options for, 54 performing player frame tasks in, 328–329 os.date(format, time) function, 157 setting font strings for sliders with, 141 os.time() function, 157 OnMessage method, 238–239 overkill argument, for events with DAMAGE OnMobKill handler, 246 suffix, 243 OnMouseWheel script handler, adding, 127 OnPlayerJoin method, 211–213 On prefix, using methods with, 211 P OnShow element, adding code to, 225 pairs, finding, 204–205 onSpellCast function, 258 parent frame, 98 creating, 261 pattern basics, in string library, 48–51 new and improved version, 262 pcall(func, arg1, arg2, ...) function, for catch- OnUpdateFuBarPlugin method, calling, 298 ing and handling error messages, 181 OnUpdateFuBarText method, 298 performance OnUpdateFuBarTooltip method, called by measuring in Lua, 362–366 LibFuBarPlugin-3.0, 298 OnUpdate script handler and, 80–81 OnUpdate script handler, 236, 281 persistence, 65 and performance, 80–81 pet frames, additional attributes for, 333 in SimpleTimingLib, 220 pet GUIDs, player and, 245 using to build a timing library, 77–81 pets, secure slash commands for, 343 OnValid script handler, alternatives to, 96 pet suffix, for unit IDs, 248 pizza timer, that comes with Deadly Boss Mods, 357 NINDEX 479 player and pet GUIDs, 245 popOrCreateFrame function, 266–267 player cards and community cards, 216 popups player frame, creating from template, attributes and event handlers for, 132–133 328–329 creating more advanced, 132–133 player link, 261 creating simple, 131–132 PlayerModel type, Lua methods, 443–444 positioning. See SetPosition method player object, creating, 208–209 powerType argument, possible values for, PLAYER_TARGET_CHANGED event, using in 458 target frame, 329 precedence points, 100–101 from higher to lower priority, 29 defining multiple, 103 in Lua, 29–30 deleting all, 101 precision .n option, in string.format function, diagrams showing available, 100 52 poker addon prefix, 32 creating first part of, 98–106 primitive operator, in Lua table, 24 creating folder and TOC file for, 98 print function, 31 POKER_BROWSER_TITLE, text attribute set hooking to add a time stamp, 157–158 to, 105 Print method, using in OnInitialize, 285 PokerClient:JoinTable() method, 236 print(os.clock()) function, using to measure Poker CreateTable frame, putting code in speed, 362 OnShow element of Scripts element priority queue, using as data structure for a of, 225 scheduler, 222 Poker_CreateTable frame, 136 profile data type, 288 Poker_CreateTable, Show() method, 136 profiling functions, calling to profile your PokerFunctions.lua, creating for building code , 363–364 auxiliary functions, 195–208 Pro OGRE 3D Programming, by Gregory poker game client Junker, 399 building, 232–240 protected frames, restrictions on, 324–325 building with addon communications, protected method, Show method as, 324 227–240 pseudo random number generators, 215 PokerLib.RateCards function, finding a hand push operation, in stacks, 161 with, 199–200 PvP (Player vs. Player) addons, used by unit poker mod flags, 256 adding a backdrop to, 136 adding a size and an anchor to, 136 creating our popup for, 134–135 Q setting options for new, 135 Quicksort, for sorting tables, 366 Poker_TableBrowser frame quotation marks (“”), strings written in, 19 defining, 98 making visible, 99–103 Poker_TableBrowser.IsSelected, called by SortTables function, 122 R Poker_TableBrowser.JoinSelectedTable() race data type, 288 function, implementing, 123–123 raid frame mod, 2 Poker_TableBrowser.SelectEntry, called by raid roles, secure slash commands for, 343 SortTables function, 122 RandomCrap addon, 354 Poker_TableBrowser.Update() method, call- random number generators, 215 ing to update buttons, 121 480 NINDEX

RANGE event, arguments for, 242 return keyword, 15 RANGE_ prefixes, arguments for, 456 return statement, 36 range type, 295 example of, 276 for a numeric value, 291 RGB color model, web site for information rawget function, 381 about, 259 |r (color reset code), 259 Rock, FuBar based on, 296 realm data type, 288 root element, in XML document, 94 receive function, in simple event handler, 367 runCmd function, 356 ReceiveHit method, 177 Runed Titanium Rod, code behind a small ReceiveHit(attacker) method, 173 link to, 260 recursion, 15 runtime errors, 181 recursive table functions, 155–156 tail calls, 154–155 recursive table functions, 155–156 S recycling, tables in Lua, 386–387 say chat, macro that sends two messages to, Region type 339 Lua methods, 410–412 Say(text) method, 173 XML attributes, 409–410 Scale option, 307–308 XML elements, 410 schedule function, 220–221 RegisterChatCommand(cmd, func) method, for timing library, 77–79 creating a slash command in Ace Schedule method, 220 with, 286 Scheduler, for timing library, 77–79 RegisterEventHandler(event, func) function, school argument, for events with DAMAGE 398 suffix, 243 RegisterEvent method, 77 SciTE (Scintilla-based Text Editor), 10 RegisterForClicks method, 109 configuration file, 394 RegisterForDrag method, adding to OnLoad customized version for writing addons, 8 script handler, 272 customizing with Lua, 393–396 RegisterForDrags method, 327 Hello, World with, 394–395 RegisterUnitWatch(frame) function, calling validating XML in, 96 for target frame, 329 web site for config commands, 394 regular expressions, available classes for, 49 web site for documentation, 396 relational operators, 26–28 script handlers relativePoint attribute, 99 Button type, 428 , 99 chat frames and, 71–72 remote control, of auctions, 90–91 ColorSelect type, 431 removeArg(n, ...) function, writing, 205 EditBox type, 435 repeat-until loops, 34 making frames draggable with, 137–138 reserved keywords, 16–17 of Frame type, 420–421 ResetCPUUsage() function, 363 ScrollFrame type, 446 reset option Slider type, 452 for cast sequence command, 344–345 element triggers available for, 344 adding to $parentTableList, 127–128 resisted argument, for events with DAMAGE suffix, 243 adding to frame for dragging, 106 response codes, AccessDenied and Server- frame script handlers contained in, 95 Full, 238 making frames draggable with, 137–138 restricted functions, 319–321 scroll frames, for lists, 123–128 NINDEX 481

ScrollFrame type select option type, 295 Lua methods, 445–446 self.BetTimeout, unscheduling calls to, 219 script handlers, 446 SendCards method, 216 XML elements, 445 SendState method, 212 Scrolling, with the mouse wheel, 127 server:Showdown() method, 217–218 ScrollingMessageFrame, chat frame type, 71 Server.lua, for building the poker server, ScrollMessageFrame type, 446–448 208–219 Lua methods, 447–448 server object, creating, 209–210 XML attributes, 447 servers table, that holds all currently running secure action button servers, 210 advanced, 335–338 SetAttribute(attribute, value) method, setting Warsong Gulch battleground mod, attributes of secure frames with, 326 334–335 SetAttribute method, of protected frames, SecureActionButtonTemplate, 331 326 secure action button templates, using, SetDefaultSize method, calling, 294 333–338 setfenv(func or level, environment) function, secure action button types, all possible val- 185 ues for, 333–334 SetFormattedText method, 371 secure and tainted code, in World of War- SetFuBarText method, 297–298 craft, 319–324 SetGeneralLocalization method, 315 secure button setglobal(name, value) function, provided by adding attributes to, 336–338 World of Warcraft, 184 XML file for, 336 SetHyperlink, calling SetOwner method SecureButton_GetModifiedAttribute helper before calling, 74 function, 331 setmetatable function, 170 securecall(func, ...) function, 322 setmetatable(table, metatable) function, 169 secure functions, hooking, 321–322 SetOwner method, 74 secure slash commands, 340 SetPoint method available for pets, 343 anchoring a frame to a nameless frame available for raid roles, 343–344 with, 105 available miscellaneous, 344 setting new point with, 101 for your (focus) target, 342–343 SetPortraitTexture(texture, unit) function, in player frame, 328 list of available for spells and items, 341 SetPosition method, creating, 270 secure state driver, in target frame, 329 SetScript, 70 secure templates SetSlot method, 239 list of, 325–326 setter function, of option, 291 using for unit frame mod, 324–333 setter option, for Width option, 307 working with, 319–338 SetText method, 371 SecureUnitButton_OnClick function, defined in FrameXML/SecureTemplates.lua, SetTexture, 240 330–331 SetUserPlaced method, 267 SecureUnitButtonTemplate, 324 shared subtables, 155 security and addon messages, 230–232 short-circuited operator, in Lua, 29 SelectEntry, 122 #show and #showtooltip commands, 353 Selection, fixing code for, 127–128 showdown state, 217–218 select option, IconLeft and IconRight pos- Show method, as protected method, 324 sible combinations, 305 482 NINDEX

ShowTestBars method, 301 Slider type, 450 calling, 305 Lua methods, 451–452 #showtooltip command, 353 script handlers, 452 showTooltip function, 74 XML attributes, 450–451 ShuffleCard method, with compare helper XML elements, 451 function, 215 sorting, the list, 121–122 SimpleHTML type, 448 sound files, playing and testing, 59 Lua methods, 449–450 sourceFlags argument, combat log events, XML attributes, 449 242 XML elements, 449 sourceGUID argument, combat log events, SimpleTimingLib 242 optimizing, 383–387 sourceName argument, combat log events, optimizing using another data structure, 242 383–384 special warnings and announces, 313–314 supporting old, 222 specWarnSurge object, warning text if Ma- updating to use LibStub, 279–283 lygos casts Power Surge on you , 247 SimpleTimingLib-1.0 SPELL_CAST_START subevents, printing to building, 280–281 chat frame, 243 TOC file for, 282–283 SPELL event, arguments for, 242 SimpleTimingLib-1.1, building simple, spellID argument, SPELL event, 242 384–386 spell link, 261 Simple Timing Library 2.0, adding object- spellName argument, SPELL event, 242 orientation to, 220–222 SPELL_ prefixes, arguments for, 456 SimpleTimingLibTest, building skeleton ad- spells don for, 279 adding new to table, 257 SimpleTimingLibTest.lua, 282–283 detecting in CooldownMonitor.lua file, element, setting frame size with, 101 256–258 _size field spellSchool argument, SPELL event, 242 in metatable in Lua, 389 Spell school bit field, bit masks for, 460 sizes or offsets, 101 –102 spell schools, 252–256 sky, creating in 3D application, 402 and unit flags, 248–256 slash command handlers checking for multiple, 254 creating, 289 square brackets ([]), using in strings, 19–20 creating for options, 304–305 stack, overflow of, 154 slash commands stack:New() constructor, 180 available, 340–346 stack overflow error message, 154 creating simple DKP, 87–89 stack pointer, in server object, 209 for disabling profiling, 363 stackPointer attribute, of server object, 215 for hunters and warlocks, 341 stacks, in Lua, 161 for moving timers, 272–273 stances condition, 348 in DevTools, 5 StartBettingRound method, 213–214 secure and normal, 340–341 StartMoving handler, 327 to enable profiling in WoW, 363 startTimer function, constructor for building sliders timer object, 266–268 basics of, 140–141 StartTimer functions, 301 for small and big blind settings, 142–143 Statements, in Lua, 31–38 setting minimum and maximum values static popup dialogs, 130–135 for, 141 StaticPopup_Show function, 130 NINDEX 483 static scoping, 151–152 T status bar timers TabardModel type, Lua methods, 444–445 building, 263–274 table browser, designing, 110–111 constructor for timer object, 268–270 TableBrowser.lua template defined by Blizzard, 263 adding code to, 223 StatusBar type adding event handler to, 224 Lua methods, 453–454 table.concat function vs. concatenation per- XML attributes, 452–453 formance, 370 XML elements, 453 table.concat(tbl, delimiter) function, in Lua, status updates, receiving, 239–240 370 stopmacro command table data type, in Lua, 22–25 used by macro, 352 table library, functions available in World of using #showtooltip with, 353 Warcraft, 53–54 StopMovingOrSizing handler, 327 tables straights, finding, 202–204 basic optimizations, 382–383 string, in Lua, 19–21 optimizing, 382–383 StringBuilder object, 369 parts of, 374–382 string.format function problem saving, 223 available directives for, 51 recycling in Lua, 386–387 optimizing in WoW, 371 using to build data structures, 160–168 options available in, 52 using to create arrays, 160–161 texture added as additional argument to, tables and functions, as expressions, 30 262 table.sort function string.gmatch function, 191–192 in Lua, 366 string.gmatch(str, pattern) function, 191 for sorting table that holds cards, 215 string.gsub function, 191–192 sorting cards with, 199 string.gsub(str, pattern, repl, n) function, 192 table.sort(t, compare) function, 366 string.join(delimiter, ...) function, in WoW, (/t), as delimeter between the prefix and 370 message, 228 string.join function, 244, 370 tail calls, in Lua, 154–155 string library, 191–192 taint, how it spreads, 322–324 basics, 45–48 taint.log file, example of, 323–324 string pool, 367 talkingUnit prototype, 177 strings stored in, 21 target and focus target, secure slash com- strings, in Lua, 367–371 mands for, 342–343 string.split command, 87 target argument, 228 for getting used strings back, 237 target frame, creating from template, 329–330 style field, 292 TargetofTarget_Update() function, 324 subevents, building event handlers for, target option, available for all secure slash 243–244 commands, 341 Subversion (SVN). See SVN repository target suffix, for unit IDs, 248 superclass, 175 templates SVN repository, web site address, 400 available secure, 325–326 Swatter, 6 building, 263–265 syncHandler function, in simple event han- creating buttons from, 114–115 dler, 367 creating for list entries, 116–118 syntax errors, handling of in WoW game, 97 creating two frames from, 328–330 484 NINDEX

defining for button, 108 TOC (table of contents) file format, 59–62 exercise, 138 TOC files, for Deadly Boss Mods, 310–311 for scroll frames, 123–124 toggle option type, 295 using group header, 331–333 tooltip content, setting , 437–439 working with secure, 319–338 tooltips |T escape-sequence, added to onSpellCast adding to FuBar plugin, 298 function, 262 using, 73–74 Test prefix, script for simple, 229 TortoiseSVN (for Windows), web site, 400 Texas Hold’em tostringall function, 244 a crash course in, 198–199 tostring(arg) function, 21 using advanced Lua to extend addon, transition actions, defined by states, 211 195–226 transitions, between finite-state machines web site for Wikipedia article, 198 states, 210 writing of example game, 93–149 traveling salesman problem, 167–168 text attribute, 105 trees, creating in 3D application, 401 textures, 105, 261–262 trinket macro, 357 adding by hand using the ele- truth table ment, 139–140 of binary AND operator, 249 escape sequence that represents, 261 of binary OR operator, 250 and font strings for edit boxes, 139–140 of binary XOR operator, 251 Texture type tuning options, for macros, 358 Lua methods, 423–424 Two-Hand condition, 348 XML attributes, 422 type field, in AceOptions table, 290 XML elements, 422 type(x) function, getting type of value with, tight loop, testing with, 372 18 attribute, in element, 102 timer broadcast system of DBM, how it per- forms checks, 231 U Timer localization, 315 element, in World of Warcraft, 94 timer object, building, 266 UIErrorsFrame, macro for clearing, 358 timers, 314 UIFrameFadeOut function, using on the canceling, 271–272 texture flash, 270 creating from template, 265 UI & Macros forum, web site address, 5 handling, 266–268 UIPanelButtonTemplate, 109 moving, 272–273 UIPanelButtonUpTexture global variable, 108 updating, 270–271 UIParent, 99 using in macros, 356–357 UIParent:GetScale() method, retrieving UI timestamp argument, combat log events, 242 scale with, 101 Timestamp function, writing, 395 UI scale setting, retrieving, 101 timestamps, that display in chat frame, 158 UI (user interface), digging through default, timing library 130–131 schedule function for, 77–79 unary minus operator, 27 using for DKP auctioneer mod, 81–92 undirected, defined, 166 using OnUpdate to build, 77–81 unified diffs, 4 TinyPad, web site address, 7 UNIT DIED handler, Deadly Boss Mods, 246 toboolean function, creating, 225 NINDEX 485 unit flags and spell schools, 248–256 V bit masks for, 254–255 values field, 292 unit flags bit field, bit masks for, 460–461 valueStep attribute, for sliders, 141 unit frame mod, using secure templates for, vararg parameter, 41 324–333 using in a table constructor, 43 unit frames variable arguments (vararg), 41–43 building a template for, 326–328 variables, in Lua, 16–17 building with attributes, 326–331 variables and metatables, saved, 222–225 using the template built for, 328–330 vector math, web site for information about, unit frame template, script handlers defined 169 in, 326–327 vectors unit functions, 462–464 function for creating, 169–170 UnitGUID, 247 implementing in a 3-dimensional space, UnitGUID(unitId) function, 254 169 UNIT_HEALTH event vehicle GUIDs, NPC and, 245 event handler needed for, 327 versioning libraries, 276–277 needed in player frame, 328–329 video options, 358 registering, 371 virtual=, 108 unit IDs checking for , 351 prefixes for, 247 primary, 461–462 W WaitForBet method, implementing, 218 suffixes for, 248 waitingForBet or showdown state, 210, 214 UnitName, 247 waitingForBet state, 218–219 UnitName(unitId) function, 89 waitingForPlayers state, 210 unit references, combat log and, 455–464 Warhammer Online unlock command, for moving timers, 272 event handlers in, 398–399 Unlock function, 301 Hello, World in, 396–399 unpack function, 78 Lua used by, 1, 393 for returning all cards, 198–198 .mod file, 397–397 unschedule function, 221, 385 web site address, 396 for timing library, 79–80 Warning localization, 315–316 using in object-oriented timing library, 220 warnings and announces, 314 unscheduler, for timing library, 79–80 Warsong Gulch battleground mod, secure action button, 334–335 UpdateAddOnCPUUsage() function, 363 weak table, 188 UpdateAddOnMemoryUsage() function, 364 web site addresses Update function, 125 Ace3 framework information, 283 Update method, for updating timers, 270–271 AceConfig-3.0 documentation, 295 Upvalues, in Lua, 154, 372 AddOn Studio IDE, 10 usedSlots attribute, in Lua, 379 API documentation of AceDB-3.0, 288 userdata metamethods, available in Lua, 389–390 author web site, 8 userdata object, using in Lua, 388–390 Blizzard list of available normal slash com- mands, 340 userdata value, 25 book information and revisions, 299 book source code download, 11 486 NINDEX

Curse, 5, 400 World of Warcraft(WOW) Deadly Boss Mods, 5, 275, 300 addon messages provided by, 227–240 Deadly Boss Mods documentation, 305, addons, 2–4 308 API functions provided by, 58 detailed diffs for all patches, 67 available metadata attributes, 60–61 DevTools, 5 bitlib in, 190 downloading bitlib, 190 CPU profiling in, 363–364 downloading FuBar, 296 default UI, 2 downloading LibFuBarPlugin-3.0, 296 frame types you can create in, 405–454 event list, 398 heavily modified UI, 2 Interface AddOn Kit, 7 in-game tools, 5–7 Java, 97 Lua used as UI by, 1 list of applications and games that use memory profiling in, 364 Lua, 393 optimizing string.format function in, 371 Lua, 2 profiling addons in, 363–364 Lua libraries and bindings, 403 running, 57, 58 LuaEdit IDE, 8 secure and tainted code, 319–324 Lua.org/Lua-users.org, 5 table.wipe(t) provided by, 386 Lugre, 399 using your own metadata attributes, 61 MPQ Editor, 7 virtual file system provided by, 58–59 official Lugre wiki, 402 XML file in, 94 OGRE 3D project, 402 World of Warcraft XML, elements in, 94–96 options available in format strings, 52 WoW (World of Warcraft) RGB color model information, 259 first addon, 58–63 SciTE documentation, 396 running a, 57, 58 SVN repository, 400 WowAce.com Swatter, 6 for LibFuBarPlugin-3.0 documentation, TinyPad, 7 299 TortoiseSVN (for Windows), 400 web site address, 277 UI & Macros forum, 5 WowAce project page, web site address, 296 vector math information, 169 WowAce/Curse, web site address, 5 Warhammer Online, 396, 399 WoW addons Wikipedia Texas Hold’em article, 198 creating our first, 58–63 wowace.com, 277 defined , 2–4 WowAce project page, 296 WoW API WowAce/Curse, 5 creating, 57, 67 WoWLua, 6 using, 62–63 WoW UI Designer, 9 Wowhead,looking up the spell on, 244 WoWWiki page, 4, 62, 360 WoWLua, in-game script editor, 6 weighted, defined, 166 WoW UI Designer, 9 while loops, 33–34 WoWWiki, table of useful pages, 4 widget or frame functions, 62 WoWWiki page, web site address, 62, 360 Width option, 307–308 wrapper function, 43 wstrings, 399 wxWidgets (wxLua), 1 NINDEX 487

XYZ XML file, in World of Warcraft, 94 XML XML-IDs, advantage of, 119 basics of, 94–96 XML terminology, 94 comments in, 94 XOR operator. See binary XOR operator creating a secure action button with, xpcall(func, errorHandler) function, for 336–338 catching/handling errors, 182 debugging, 97–98 elements, defining textures with, short overview of, 115–116 108 showing file that includes Lua file and XML file, 95 validating and debugging, 96–98 validating in SciTE, 96 XML and frames, using, 93–149 XML attributes Button type, 424 CheckButton type, 428 ColorSelect type, 430 Cooldown type, 429 EditBox type, 432 FontString type, 421 Font type, 407 Frame type, 412–413 MessageFrame method, 439 Model type, 441 Object type, 405–406 Region type, 409–410 ScrollMessageFrame type, 447 SimpleHTML type, 449 Slider type, 450–451 StatusBar type, 452–453 Texture type, 422 XML document, root element in, 94 XML elements, 94 Button type, 424–425 CheckButton type, 428 EditBox type, 432, 440 Font type, 407–408 Frame type, 413–414 MessageFrame method, 440 Model type, 441 Region type, 410 ScrollFrame type, 445 SimpleHTML type, 449 Slider type, 451 StatusBar type, 453 Texture type, 422