About Lua
Lua is a small programming language that applications can embed. LuaHUD uses it to let you write your own HUD.
This guide starts from zero. Read the pages in order:
- Variables: store and name values.
- Operators: calculate and compare values.
- Conditionals: choose which code runs.
- Loops: repeat code.
- Functions: reuse code and pass callbacks.
- Tables: group values together.
- Strings and Math: format text and numbers.
- Modules: share code between files.
- Common Errors: find and fix mistakes.
Trying the examples
Section titled “Trying the examples”Put the examples in a .lua profile in your profile directory. lh is the global LuaHUD API. We use lh.drawln(value) to draw a value and start a new line.
Examples often use made-up values, such as local fps = 120, so you can try them without looking up the game API first. These values do not update themselves from Minecraft.
Text after -- is a comment. Lua ignores it:
-- This is a comment.lh.drawln("Hello, World!") -- This is also a comment.Lua is case-sensitive: name and Name are different variables. You do not need semicolons at the end of lines.
These lessons use Lua 5.2 syntax. For advanced topics, such as metatables and coroutines, see the official Lua 5.2 manual.