The standard library is a set of wowlua:* modules for what nearly every WoW
addon needs: events, saved variables, slash commands, timers, an options page,
a minimap button and more. This page shows how to use them and which module
covers what.
Import what you use
Nothing from the standard library is in scope until you import it. The modules
have names that start with wowlua:, and you import from them as from any
other module.
The modules are written in wowlua and ship inside the compiler. Only the
modules your addon uses are compiled into it, and of those only the code it
uses. Their version is the compiler's version.
A small addon, start to finish
Six imports cover what most addons write by hand or embed from libraries:
saved settings, a login hook, an event handler that doesn't run too often, and
a slash command.
There is no event frame with an OnEvent script, no SLASH_MYADDON1 global
and no ADDON_LOADED handler that checks the addon's name. The decorators
generate that registration code when the addon is compiled.
What you get over embedding libraries
Your own copy. Each addon gets a private copy of the modules it uses,
compiled into it. Two addons built with different wowlua versions never
share, or fight over, a library.
Types. Event payloads, slash command arguments, settings keys and saved
data are typed and checked. A misspelled event name is a compile error, not a
handler that never runs.
Fits each client. The modules adapt to the game flavor at compile time,
and use only what that client has. Where a module needs an API a flavor
lacks, it has a fallback (warning W8301 when the fallback does less) or
reports error E8300.
Safe around startup. Modules that need saved data or the UI wait for the
right moment by themselves, so you can set them up at the top of a file.
One failing handler doesn't stop the others. Every callback runs
isolated. Its error goes to the game's error handler with your addon's name
in front, so error display addons still catch it.
error[E8003]: unknown event or message `PLAYER_TARGET_CHANGD` ┌─ src/main.wowlua:26:8
│26 │ @event("PLAYER_TARGET_CHANGD")
│^^^^^^^^^^^^^^^^^^^^^^ not declarederror: aborting due to 1 previous error
A typo in an event name is caught before the game loads the file. The
WoW API reference lists every event and function.
What you no longer write by hand
The chore
The module
Registering events on a frame, coalescing bursts of them
wowlua:events
Waiting for ADDON_LOADED and PLAYER_LOGIN
wowlua:lifecycle
Defaults, profiles and migrations of SavedVariables
wowlua:saved
Parsing slash command text; printing with your addon's name
wowlua:slash, wowlua:log
Keeping track of timers; throttling and debouncing
wowlua:timer
Building an options panel
wowlua:settings
A draggable minimap button
wowlua:launcher
Translation tables
wowlua:locale
Splitting addon messages into chunks; serializing and compressing data
wowlua:comm, wowlua:serialize
Callbacks other addons can register for
wowlua:callbacks
Post-hooks on Blizzard's functions and scripts
wowlua:hooks
Find the module for the job
Events and startup
Module
Use it to
Page
wowlua:events
Handle WoW events, unit events and your own messages