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.

xviContentsExtending Tables with Metatables 68Adding a Metatable 68Defining Metamethods 69Defining Basic Arithmetic Using ___add, ___sub, ___mul,<strong>and</strong> ___div 70Defining Negation Using ___unm 71<strong>Creating</strong> Meaningful Output with ___tostring 71Concatenating Tables Using ___concat 72Exploring Fallback Tables with ___index 72Catching Creation <strong>of</strong> Keys with ___newindex 74Bypassing Metatables 75value = rawget(tbl, key) 75rawset(tbl, key, value) 76Summary 76Chapter 5 Advanced Functions <strong>and</strong> Control Structures 77Multiple Return Values 77Converting Hex to RGB 77Assigning Multiple Values 78Missing Return Values? 79Multiple Return Values in <strong>World</strong> <strong>of</strong> <strong>Warcraft</strong> 79Using a Dummy Variable 80Using the select() Function 81Accepting a Variable Number <strong>of</strong> Arguments 81Declaring a Vararg Function 82Using select() with ... 83Generic <strong>for</strong> Loops <strong>and</strong> Iterators 84Syntax <strong>of</strong> Generic <strong>for</strong> 84Traversing the Array Part <strong>of</strong> a Table 85Traversing an Entire Table 86Clearing a Table 86Using Other Iterators 87Sorting an Array <strong>of</strong> Table Data 87Define Example Data 88Default Sort Order 88<strong>Creating</strong> a Comparison Function 88<strong>Creating</strong> a More Complex Sort Function 89Summary 90Chapter 6 Lua St<strong>and</strong>ard Libraries 91Table Library 92str = table.concat (table [, sep [, i [, j]]]) 92table.insert (table, [pos,] value) 92max = table.maxn (table) 93

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

Saved successfully!

Ooh no, something went wrong!