Macros
Lunex macros give you compile-time control over obfuscation. Gate debug code, encrypt values, skip virtualization for hot paths, and crash on tampering. All macros are resolved at compile time and never appear in obfuscated output.
Quick start
Drop the Full Shim Block at the bottom of this page into your script for local development. It is automatically excluded from obfuscated builds.
LUNEX_OBFUSCATED
Expands to true at compile time. Use it to gate debug-only code that should never appear in obfuscated output. Dead branches are fully stripped.
if not LUNEX_OBFUSCATED then
print("dev mode") -- removed entirely from output
endLUNEX_CRASH()
Permanently halts the current thread. Silent, no console output, no error message, and no traceback. Every call site appears structurally different in the obfuscated output.
if tampered then
LUNEX_CRASH()
endgetfenv().LUNEX_CRASH = function()
while true do end
endLUNEX_ENCSTR("string")
Encrypts a string literal at compile time. Decrypted automatically at runtime using a per-build cipher. The argument must be a string literal.
local url = LUNEX_ENCSTR("https://example.com/api")getfenv().LUNEX_ENCSTR = function(s)
return s
endLUNEX_ENCNUM(number)
Works like LUNEX_ENCSTR but for numeric literals. Supports both integers and floating point values.
local port = LUNEX_ENCNUM(8443)getfenv().LUNEX_ENCNUM = function(n)
return n
endLUNEX_ENCFUNC(fn)
Recommended form. Encrypts a function at compile time. Lunex automatically generates keys and handles decryption.
1local fn = LUNEX_ENCFUNC(function()
2 return doSomethingSecret()
3end)
4
5fn()LUNEX_ENCFUNC(fn, encKey, decKey)
Advanced form allowing custom encryption and runtime decryption keys.
1local fn = LUNEX_ENCFUNC(
2 function()
3 return doSomethingSecret()
4 end,
5 "a1b2c3d4...64hexchars...e5f6",
6 getKeyFromServer()
7)
8
9fn()getfenv().LUNEX_ENCFUNC = function(fn, _e, _d)
return fn
endLUNEX_NO_VIRTUALIZE(fn)
Skips custom VM virtualization while still allowing variable renaming and other AST transformations. Ideal for performance-critical callbacks.
1local render = LUNEX_NO_VIRTUALIZE(function(dt)
2 -- native Luau
3end)
4
5RunService.RenderStepped:Connect(render)
6
7-- Inline usage:
8LUNEX_NO_VIRTUALIZE(function()
9 ...
10end)()getfenv().LUNEX_NO_VIRTUALIZE = function(...)
return ...
endLUNEX_NO_UPVALUES(fn)
Runs a function without captured upvalues using setfenv sandboxing. Useful for isolated execution. Requires loadstring.
1local fn = LUNEX_NO_UPVALUES(function()
2 ...
3end)
4
5fn()getfenv().LUNEX_NO_UPVALUES = function(...)
return ...
endLUNEX_LINE / LPH_LINE
Text-level substitution that expands to the current source line number before parsing.
1local line = LUNEX_LINE
2
3-- becomes:
4local line = 47Reserved Prefix Guard
Any identifier beginning with LUNEX_ or LPH_ that is not a recognized macro produces a compile-time error. These prefixes are reserved exclusively for Lunex macros.
1-- This will cause a compile-time error:
2local x = LUNEX_UNKNOWN_MACRO()
3
4-- Only recognized macros are allowed:
5local ok = LUNEX_OBFUSCATED -- validFull Shim Block
Complete shim definitions for all Lunex macros, enabling code to run unobfuscated during development.
1if not LUNEX_OBFUSCATED then
2 local e = getfenv()
3
4 e.LUNEX_CRASH = function()
5 while true do end
6 end
7
8 e.LUNEX_ENCSTR = function(s)
9 return s
10 end
11
12 e.LUNEX_ENCNUM = function(n)
13 return n
14 end
15
16 e.LUNEX_ENCFUNC = function(fn)
17 return fn
18 end
19
20 e.LUNEX_NO_VIRTUALIZE = function(...)
21 return ...
22 end
23
24 e.LUNEX_NO_UPVALUES = function(...)
25 return ...
26 end
27
28 e.LUNEX_OPAQUE = function(x)
29 return x
30 end
31endNeed help or have questions?