Documentation
A practical reference for Luaq macros, protection controls and build behavior. Both LUAQ_ and LPH_ prefixes are supported.
Overview
Luaq macros enforce compile-time protection and structural isolation. Standard LUAQ_ macros are available across the whole pipeline.
Dev shim rule: always place development shims inside an if not LUAQ_OBFUSCATED then ... end block. The pipeline strips these blocks entirely during build generation.
LUAQ_OBFUSCATED
Expands directly to the boolean true at compile time. Use this macro to gate development or debug code that must never leak into the production output. Dead branches inside `if not LUAQ_OBFUSCATED then` are pruned during parsing.
if not LUAQ_OBFUSCATED then
print("dev mode active") -- Completely removed from obfuscated build
end
LUAQ_INLINE(fn)
A high-performance compile-time macro that eliminates helper closure overhead by directly substituting the helper body into supported call sites during obfuscation. It removes call-boundary costs while preserving full virtualized runtime protection.
Key performance & internal mechanics
- Hygienic scope cloning: each callsite receives clean variable bindings with zero register or local leaks.
- Single-pass argument evaluation: arguments are evaluated in deterministic order exactly once before scope substitution.
- Full virtualization: inlined AST code is merged and fully virtualized alongside the rest of your script.
- Safety limits: a maximum threshold of 256 AST nodes for tight, low-latency target functions.
- Compatibility: single expressions, blocks with control flow, multiple returns in assignment positions, nested inline helpers, and read-only stable upvalues / table field mutations.
-- Expression helper
local add = LUAQ_INLINE(function(a, b)
return a + b
end)
print(add(10, 20))
-- Block helper with loop control flow
local sumDownTo = LUAQ_INLINE(function(start, stop)
local total = 0
for i = stop, start do
total = total + i
end
return total
end)
local result = sumDownTo(10, 1)
-- Multiple returns in assignments
local pair = LUAQ_INLINE(function(a, b)
return a + b, a * b
end)
local sum, product = pair(3, 4)
-- Captured read-only upvalues & table mutations
local state = { clicks = 0 }
local bump = LUAQ_INLINE(function(amount)
state.clicks = state.clicks + amount
return state.clicks
end)
print(bump(2))
-- Development shim
getfenv().LUAQ_INLINE = function(fn) return fn end
LUAQ_CRASH()
Permanently halts execution on the current thread silently. It triggers no console log, no traceback, and no engine error dialog. Each invocation expands into structurally randomized instructions at every call site to hinder static pattern matching.
if tampered then
LUAQ_CRASH()
end
-- Development shim
getfenv().LUAQ_CRASH = function() while true do end end
LUAQ_ENCSTR(string)
Encrypts a string literal at compile time. At runtime the payload is dynamically decrypted using an auto-injected routine linked to a per-build cipher. The input must be a raw string literal - variables and dynamic concatenations are not permitted.
local apiEndpoint = LUAQ_ENCSTR("https://api.internal.domain/v1/authenticate")
-- Development shim
getfenv().LUAQ_ENCSTR = function(s) return s end
LUAQ_ENCNUM(number)
Encrypts numerical constants at compile time. The obfuscator serializes integer and float values, encrypting them into a form decrypted during execution. The argument must be a static number literal.
local bindPort = LUAQ_ENCNUM(8443) -- Development shim getfenv().LUAQ_ENCNUM = function(n) return n end
LUAQ_ENCFUNC(fn)
Encrypts an entire function target at compile time. Supports two operational signatures.
Signatures
- 1-argument form (recommended): pass only the function target. Key generation and runtime decryption are handled automatically by the obfuscator.
- 3-argument form (advanced): specify custom encryption and decryption keys. Useful when fetching runtime keys from a remote server. Requires a unique 64-character hex string for the encryption key and a dynamic expression for the decryption key.
-- 1-arg form (standard)
local protectedTask = LUAQ_ENCFUNC(function()
return executeCriticalRoutine()
end)
protectedTask()
-- Development shim
getfenv().LUAQ_ENCFUNC = function(fn, _e, _d) return fn end
LUAQ_NO_VIRTUALIZE(fn)
Exempts a function from being converted into custom bytecode for the virtual machine. The target function still undergoes identifier renaming, control flow adjustments and AST-level transformations. Use this for high-frequency callbacks or tight loops to maintain native performance.
local renderStep = LUAQ_NO_VIRTUALIZE(function(deltaTime)
-- Executes directly in Luau native scope
end)
RunService.RenderStepped:Connect(renderStep)
-- Development shim
getfenv().LUAQ_NO_VIRTUALIZE = function(...) return ... end
LUAQ_NO_UPVALUES(fn)
Prevents a function from capturing upvalues in its lexical scope by applying environment-based isolation. Useful when running routines in sandboxed execution contexts. Requires environment string evaluation support in the execution layer.
local isolatedFn = LUAQ_NO_UPVALUES(function()
-- Isolated execution scope
end)
isolatedFn()
-- Development shim
getfenv().LUAQ_NO_UPVALUES = function(...) return ... end
LUAQ_LINE
Replaced with the source code line number as a plain integer literal before AST parsing. This is a text-level pre-pass substitution, not a function call. Calling LUAQ_LINE() like a function will throw a syntax error.
local currentLine = LUAQ_LINE -- becomes: local currentLine = 42
Aggressive Optimizations
Optimizes your source code before obfuscating and applies AST transformation passes during obfuscation to streamline execution speed and minimize memory overhead.
When enabled, the pipeline executes constant folding, dead code elimination, expression simplification and VM register reuse optimizations prior to applying encryption layers.
Enhanced VM Compression
Reduces the size of the emitted virtual machine payload. Recommended when shipping large scripts where the final build size matters.
Reserved Prefix Guard
Any identifier beginning with LUAQ_ that does not match an established macro will trigger a compile-time error. Do not prefix standard local variables or custom functions with these reserved strings.
Full Shim Block
Place this shim header at the entry point of your source code during development. When processed by the Luaq pipeline, the entire outer block folds to if false then ... end and is completely removed from the final obfuscated binary.
if not LUAQ_OBFUSCATED then
local env = getfenv()
env.LUAQ_INLINE = function(fn) return fn end
env.LUAQ_CRASH = function() while true do end end
env.LUAQ_ENCSTR = function(s) return s end
env.LUAQ_ENCNUM = function(n) return n end
env.LUAQ_ENCFUNC = function(fn, _e, _d) return fn end
env.LUAQ_NO_VIRTUALIZE = function(...) return ... end
env.LUAQ_NO_UPVALUES = function(...) return ... end
env.LUAQ_OPAQUE = function(x) return x end
end