---
name: lua-basics
description: Effective Lua programming for FiveM - functions, tables, variables, conditionals, error handling. Use when writing or reviewing Lua code for FiveM resources.
author: germanfndez
version: 1.0.0
mcp-server: projecthub
---

# Lua Basics

Best practices for writing effective Lua code in FiveM. This skill covers fundamental Lua patterns, performance optimizations, and code quality guidelines specifically for FiveM development.

## When to use

- Writing or reviewing Lua code for FiveM resources.
- Questions about Lua best practices, naming conventions, or code structure.
- Optimizing Lua code for performance.
- Need guidance on functions, tables, variables, conditionals, or error handling in Lua.

## How to use

Read individual rule files for detailed explanations and examples:

- **rules/functions.md** — Function best practices: size, naming, parameters, exports, guard clauses.
- **rules/tables.md** — Table operations: array indices, dereferencing, avoiding table.insert, iterations, array size.
- **rules/variables.md** — Variable naming conventions: constants, locals, globals, enums vs booleans.
- **rules/conditionals.md** — Conditional patterns: default values, boolean expressions, readability.
- **rules/errors.md** — Error handling: assertions, pre-conditions, errors as values, fail loudly.
- **rules/reference-links.md** — Official Lua and FiveM documentation resources.
