Score Tracker - Lua Typing CST Test
Loading…
Score Tracker — Lua Code
Tracks a score with increment, decrement, and reset.
score = 0
function updateUI()
print('Score: ' .. score)
end
function increment()
score = score + 10
updateUI()
end
function decrement()
score = score - 5
updateUI()
end
function reset()
score = 0
updateUI()
end
-- Simulate actions
updateUI()
increment()
decrement()
reset()Lua Language Guide
Lua is a lightweight, high-level, multi-paradigm scripting language designed for embedded use in applications. It emphasizes simplicity, portability, and performance, and is widely used in games, embedded systems, and scripting engines.
Primary Use Cases
- ▸Scripting in video games (e.g., Roblox, World of Warcraft, Angry Birds)
- ▸Embedded scripting in applications
- ▸Configuration and automation scripts
- ▸Rapid prototyping and DSLs (domain-specific languages)
- ▸Network services and lightweight servers
Notable Features
- ▸Small and lightweight runtime
- ▸Fast execution and JIT compilation (with LuaJIT)
- ▸Dynamic typing and automatic memory management
- ▸First-class functions and closures
- ▸Extensible via C API
Origin & Creator
Created in 1993 by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, and Waldemar Celes at PUC-Rio, Brazil.
Industrial Note
Lua is specialized for embedding in applications such as video games, simulation software, and network applications, allowing host programs to expose custom APIs to Lua scripts.