12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

542 Part IV ■ <strong>Reference</strong>API Meta-TypesTo clarify the documentation <strong>of</strong> API functions, we have created a number <strong>of</strong> meta-typesthat are used to describe what sort <strong>of</strong> values are accepted in an argument or returnedfrom an API function. These are not actual Lua types, but a classification <strong>of</strong> acceptedvalues in various API sub-systems. When a meta-type applies to an argument or returnvalue, this is indicated after the Lua type in the argument listing. Meta-types enableyou to consolidate the documentation <strong>for</strong> classes <strong>of</strong> API functions, rather than having todocument the same list <strong>of</strong> values over <strong>and</strong> over again. This section describes these types.1nilMany API functions use values indicative <strong>of</strong> a binary state but do not utilize theBoolean true <strong>and</strong> false values in Lua. Due to the way the functions are limited, theyuse the number value 1 <strong>for</strong> true,<strong>and</strong>nil <strong>for</strong> false. Because Lua treats nil as a falsevalue <strong>and</strong> any non-nil value as true in a conditional, these values can generally beused the same as Boolean values in conditional statements (such as if IsInGuild()then ... end). However, you should avoid making direct comparisons using thistype <strong>of</strong> value: <strong>for</strong> example, the condition if IsInGuild() == true then ... endwill never be triggered. These types <strong>of</strong> variables are called 1nil values, to distinguishthem from Boolean values.actionIDThe actionID meta-type is used to identify one <strong>of</strong> the player’s action bar slots. InUI terms, action bar slots are a layer <strong>of</strong> abstraction between spells or items <strong>and</strong> themechanisms available to the player <strong>for</strong> using them conveniently. For example, instead<strong>of</strong> the default UI internally using SetBindingSpell(), SetBindingMacro(), <strong>and</strong>so on whenever the player changes the contents <strong>of</strong> the visible action bars, it insteadmanages a set <strong>of</strong> key bindings corresponding to the action bar slots.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!