Client UI Lua Script API - Kyoril/mmo GitHub Wiki

Summary

The user interface of the game is powered by the Lua scripting language. This page shall offer an API documentation. The user interface is divided into two sections: The glue screens and the actual Game UI. Glue screens are stuff like the login screen, the realm selection, the character selection and the character creation screen.

Common things

Accessing frames in lua

Each frame is automatically exposed as a global variable which is named like the frame name. So if you have the following Xml:

<Frame name="MyFrame" ...>
   <!-- ... -->
</Frame>

Then you can access it in lua simply using the global "MyFrame":

MyFrame:SetText("Hello world!");

Most event callbacks will also provide a reference to the frame as the first argument which will usually be named self or this.

Game UI

Unit Functions

Unit Name Values

Unit Functions get data from a named unit. The unit names are constants to describe which unit you are targeting so you wont have to work with actual guids etc. in the UI.

Currently there are two unit name values supported:

Name Description
player Refers to the unit which the player is currently controlling.
target Refers to the unit which the currently controlled player unit is targeting.

When working with unit functions, they return nil when the named unit does not exist or if you use any unit name value that is not supported by the client.

Stats

ID Name Description
0 Stamina Stamina stat increases the max health of the unit.
1 Strength Strength stat increases the melee attack power as well as the block value of the unit.
2 Agility Agility increases the melee or range attack power as well as the crit chance and armor of the unit.
3 Intellect Intellect increases the maximum mana of the unit as well as the magic crit chance.
4 Spirit Spririt increases the out of combat mana and health regeneration of the unit.

Functions

Name Arguments Sample Description
UnitName string unitName UnitName("player") Returns the name of the player controlled unit as string.
UnitExists string unitName UnitExists("target") Returns true if the unit is exists, so in this sample, when the player has a target. False otherwise.
UnitHealth string unitName UnitHealth("player") Returns the current amount of health of the unit. Returns 0 if unit does not exist.
UnitHealthMax string unitName UnitHealthMax("player") Returns the maximum amount of health of the unit. Returns 0 if the unit does not exist.
UnitMana string unitName UnitMana("player") Returns the amount of mana the unit has. Returns 0 if the unit does not exist.
UnitManaMax string unitName UnitManaMax("player") Returns the maximum amount of mana the unit has. Returns 0 if the unit does not exist.
UnitLevel string unitName UnitLevel("player") Returns the level of the unit. Returns 1 if the unit does not exist.
UnitStat string unitName, uint statId base, modifier = UnitStat("player", 0) Returns the base value and a modifier of the stat. The total value is value + modifier. If modifier is > 0, the stat is buffed by some temporary effects, if modifier is < 0 it is decreased temporarily. Both values are -1 if the unit does not exist.
UnitArmor string unitName base, modifier = UnitArmor("player") Returns the base value and modifier of the units armor value. Total armor value is base + modifier. Both values are -1 if the unit does not exist.
⚠️ **GitHub.com Fallback** ⚠️