Feature Flag
CfxLua-Specific Features
Compound Assignment Operators
CfxLua extends Lua with C-style compound assignment operators. Location:full_moon::ast::compound::CompoundAssignment
Examples
Safe Navigation Operator
Safe navigation using?. prevents nil errors when accessing nested properties.
In Unpacking
Shorthand syntax for unpacking table fields into local variables.Set Constructors
Shorthand for creating sets (tables where keys are set totrue).
C-Style Comments
CfxLua supports both single-line and multi-line C-style comments.Compile-Time Jenkins Hashes
Backtick syntax for compile-time string hashing using Jenkins hash algorithm.Usage Example
Compound Operator Methods
CompoundAssignment
new(lhs: Var, compound_operator: CompoundOp, rhs: Expression) -> Selflhs(&self) -> &Var- The variable being assigned tocompound_operator(&self) -> &CompoundOp- The compound operator usedrhs(&self) -> &Expression- The right-hand side expressionwith_lhs(self, lhs: Var) -> Selfwith_compound_operator(self, compound_operator: CompoundOp) -> Selfwith_rhs(self, rhs: Expression) -> Self
CompoundOp
token(&self) -> &TokenReference- Returns the token reference for the operator
Inherited Features
Sincecfxlua enables lua54, lua53, and lua52, you also get:
- Variable attributes like
<const>and<close>(see Lua 5.4) - Bitwise operators (see Lua 5.3)
- Goto statements and labels (see Lua 5.2)
- All Lua 5.x syntax features
Comparison with Luau
Both Luau and CfxLua extend Lua, but serve different purposes:| Feature | CfxLua | Luau | |
|---|---|---|---|
| Compound operators | +=, -=, *=, /=, ^=, <<=, >>=, &=, ` | =` | +=, -=, *=, /=, ^=, //=, %=, ..= |
| Type system | No | Yes (full gradual typing) | |
| Safe navigation | Yes (?.) | No | |
| In unpacking | Yes | No | |
| Set constructors | Yes (.field) | No | |
| C-style comments | Yes (//, /* */) | No | |
| Jenkins hashes | Yes (backticks) | No (backticks are string interpolation) | |
| String interpolation | No | Yes | |
| If expressions | No | Yes |
Notes
- CfxLua is designed for game scripting in FiveM/RedM environments
- The Jenkins hash feature is specifically useful for game engine identifiers
- Safe navigation can significantly reduce nil-checking boilerplate
- In unpacking is particularly useful for destructuring configuration tables
- Set constructors provide a cleaner syntax for flag-like tables
- All CfxLua features are compile-time syntax extensions and don’t require runtime support