Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
Title Page
Copyright
Dedication
Contents at a Glance
Contents
About the Author
Acknowledgments
Introduction
CHAPTER 1: Getting Started
What Is Lua?
What Are WoW Addons?
Useful Programs, Tools, and Web Sites
Web Sites
In-Game Tools
Programs
IDEs
CHAPTER 2: Lua Basics
Using Lua
Basics
Variables and Data Types
Data Types
Dynamic Typing
Expressions
Arithmetic Operators
Relational Operators
Logical Operations
Precedence
Tables and Functions as Expressions
Statements
Function Calls
Control Structures
break
return
Assignments
Local Variables
Variable Arguments
Lua Standard Libraries
The Math Library
String Library Basics
The Table Library
The Debug Library
The Operating System Library
Summary
CHAPTER 3: Using the WoW API to Create a “Hello, World” Mod
Running a “Hello, World” in WoW
Our First WoW Addon
Folder Structure
The TOC File Format
Using the WoW API
Creating Slash Commands
Persistence
Extracting the Default UI
Summary
CHAPTER 4: Working with Game Events
Using Frames as Event Listeners
Creating ChatlinkTooltips
Chat Frames and Their Script Handlers
Item Links
Using Tooltips
OnEvent
Event Handler Basics
Event Handlers for Multiple Events
Using OnUpdate to Build a Timing Library
The Scheduler
The Unscheduler
OnUpdate and Performance
Using the Timing Library for a DKP Mod
Variables and Options
Local Functions and Their Scope
Starting Auctions
Ending Auctions
Placing Bids
Creating Slash Commands
Canceling Auctions
Remote Control
Hiding Chat Messages
Summary
CHAPTER 5: Using XML and Frames
XML Basics
XML Terminology
Elements in World of Warcraft XML
Validating and Debugging XML
Validating XML in SciTE
Debugging XML
Frame Basics
Making It Visible
Layers and Textures
Movable Frames
Inheritance
The Frame Type Button
Buttons in XML
Using a Button Template
Designing the Table Browser
Simple Buttons
Building a List Element
Creating a Border
Creating a Template for the Headers
Using the Template
A Short Overview of Our XML
Creating a Template for the Entries
Creating the Buttons
Sorting the List
Selecting Elements in the List
Scroll Frames for Lists
More Buttons and Static Popup Dialogs
More Buttons
Static Popup Dialogs
More Frame Types
Another Normal Frame
Edit Boxes
Sliders
Check Buttons
OK and Cancel Buttons
An Overview of the Whole XML File
Summary
CHAPTER 6: Advanced Lua
More About Functions
Static Scoping
Closures
Recursion, Part 1: Tail Calls
Recursion, Part 2: Recursive Table Functions
Hooking
More About the Generic for Loop
Using Tables to Build Data Structures
Arrays
Stacks
Doubly Linked Lists
Graphs
Metatables and Metamethods
Overloading Operators
Available Metamethods
Object Orientation
The Colon Operator
The __index Metamethod and Constructors
Inheritance
Multiple Inheritance
Object Orientation and Data Structures
Handling Errors
Catching Errors
Throwing Errors
The Environment
The Garbage Collector
The Old Lua 5.0 Garbage Collector
Incremental Garbage Collection
Weak References
Controlling the Garbage Collector
Testing the Garbage Collector
More About Lua Libraries
The Bit Library
The String Library: Part 2
Summary
CHAPTER 7: Using Advanced Lua to Extend the Texas Hold'em Poker Addon
Building Auxiliary Functions
Creating Cards
Getting Cards
Extracting and Rating the Best Hand
Calculating a Rating
Finding and Rating the Hand
Building the Server
Creating a Player Object
Creating a Server Object
Finite-State Machines
Joining a Game
Starting Betting Rounds
Shuffling and Drawing Cards
Player Cards and Community Cards
Moving the Dealer Button
The Showdown
Waiting for Bets
Simple Timing Library 2.0
Object-Oriented Timing Library
Supporting the Old Timing Library
Using Another Data Structure?
Saved Variables and Metatables
The Problem: Saving Tables
The Solution: Metatables
Summary
CHAPTER 8: Building a Poker Game Client with Addon Communication
Addon Communication Basics
Sending Messages
Receiving Messages
Playing Around with Addon Messages
Security and Addon Messages
Building the Poker Client
The Different Message Types We Need
Sending Game Announcements
Receiving Game Announcements
Joining Games
Receiving Status Updates
Summary
CHAPTER 9: Using the Combat Log to Build a Cooldown Monitor
Working with Combat Log Events
Combat Log Arguments
Building an Event Handler
Working with GUIDs and Units
NPC and Vehicle GUIDs
Player and Pet GUIDs
GUID Examples
Unit IDs
Unit Flags and Spell Schools
Bit Fields
Spell Schools
Unit Flags
Building a Cooldown Monitor
Detecting Spells
Using Escape Sequences in Chat Frames
Building Status Bar Timers
Summary
CHAPTER 10: Using Libraries
Embedded Libraries
Versioning Libraries
Problems with Embedded Libraries
Using LibStub
Creating Our Own Embedded Library
The Ace Framework
A Simple Hello, World Addon with Ace3
Advanced “Hello, World” with Ace3
Slash Commands with AceConsole
Creating FuBar Plugins
Embedding LibFuBarPlugin-3.0
Using LibFuBarPlugin-3.0
Improving CooldownMonitor with Deadly Bar Timers
Getting Started
First Steps with DBT
Integrating DBT in CooldownMonitor
Adding Options
Deadly Boss Mods
Introduction to DBM
DBM TOC Files
Boss Mods
Localizing Boss Mods
Summary
CHAPTER 11: Working with Secure Templates
Secure and Tainted Code
Restricted Functions
Hooking Secure Functions
How Taint Spreads
Using Secure Templates for a Unit Frame Mod
Restrictions on Protected Frames
Available Secure Templates
Building Unit Frames with Attributes
Using Group Header Templates
Using Secure Action Button Templates
A Simple Secure Action Button
An Advanced Secure Action Button
Summary
CHAPTER 12: Macros
Available Commands
Secure and Normal Slash Commands
The Target Option
List of Secure Commands
Cast Sequences
Item Slot IDs
Conditions
Available Conditions
Combining Conditions
Simple Control Structures
Macro Feedback
Circumventing the 255-Character Limit
Using Lua in Macros
Sending Chat Messages
Timers in Macros
Suppressing Errors
Tuning Options
Circumventing the [flyable] Bug
Summary
CHAPTER 13: Tips, Tricks, and Optimization
Measuring Performance
Measuring Performance in Lua
Profiling Addons in World of Warcraft
Some Conventions
The Main Rules of Optimization
Strings
Understanding Strings
Example: Concatenation in Addon Communication
Optimizing string.format
Local Variables
Global Variables vs. Local Variables
What Does It Mean?
Tables
Understanding Arrays
Understanding Hash Tables
Basic Table Optimizations
Optimizing SimpleTimingLib
Using Another Data Structure
Building SimpleTimingLib-1.1
Recycling Tables?
Utilizing Userdata
Using Userdata as a Proxy
Userdata Metamethods
The Coroutine Library
Coroutine Basics
A Coroutine Example
Summary
CHAPTER 14: Other Uses for Lua
Customizing SciTE with Lua
Hello, World with SciTE
Event Handlers
SciTE Documentation
Lua in Warhammer Online
Hello, World in Warhammer Online
Documentation
Lua and Lugre
Setting Up Lugre
Creating a Simple 3D Application
Documentation
Summary
APPENDIX A: Frame Reference
Object
XML Attributes
Lua Methods
Font
XML Attributes
XML Elements
Lua Methods
Region
XML Attributes
XML Elements
Lua Methods
Frame
XML Attributes
XML Elements
Lua Methods
Script Handlers
FontString
XML Attribute
Lua Methods
Texture
XML Attributes
XML Elements
Lua Methods
Button
XML Attributes
XML Elements
Lua Methods
Script Handlers
CheckButton
XML Attributes
XML Elements
Lua Methods
Cooldown
XML Attributes
Lua Methods
ColorSelect
XML Elements
Lua Methods
Script Handlers
EditBox
XML Attributes
XML Elements
Lua Methods
Script Handlers
GameTooltip
Lua Methods
MessageFrame
XML Attributes
XML Elements
Lua Methods
Model
XML Attributes
XML Elements
Lua Methods
PlayerModel
Lua Methods
DressUpModel
Lua Methods
TabardModel
Lua Methods
ScrollFrame
XML Elements
Lua Methods
Script Handlers
ScrollingMessageFrame
XML Attributes
Lua Methods
SimpleHTML
XML Attributes
XML Elements
Lua Methods
Slider
XML Attributes
XML Elements
Lua Methods
Script Handlers
StatusBar
XML Attributes
XML Elements
Lua Methods
APPENDIX B: Combat Log and Unit Reference
Combat Log Events
Standard Arguments
Additional Arguments for the Prefixes SPELL_ and RANGE_
Additional Argument for the Prefix ENVIRONMENTAL_
Additional Arguments for the Suffix _DAMAGE
Additional Arguments for the Suffix _HEAL
Additional Arguments for the Suffix _MISSED
Additional Argument for the Suffix _FAILED
Additional Argument for the Suffix _EXTRA_ATTACKS
Additional Arguments for the Suffixes _ENERGIZE, _DRAIN, and _LEECH
Additional Arguments for Dispels and Interrupts
Additional Arguments for Buff Events
Additional Arguments for Damage Shield Events
Additional Arguments for Enchant Events
The Spell School Bit Field
The Unit Flags Bit Field
Unit IDs
Unit Functions
Index
← Prev
Back
Next →
← Prev
Back
Next →