Reference

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.

01

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
end
02

LUNEX_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()
end
Shim (development only)
getfenv().LUNEX_CRASH = function()
    while true do end
end
03

LUNEX_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")
Shim (development only)
getfenv().LUNEX_ENCSTR = function(s)
    return s
end
04

LUNEX_ENCNUM(number)

Works like LUNEX_ENCSTR but for numeric literals. Supports both integers and floating point values.

local port = LUNEX_ENCNUM(8443)
Shim (development only)
getfenv().LUNEX_ENCNUM = function(n)
    return n
end
05

LUNEX_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()
06

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()
Shim (development only)
getfenv().LUNEX_ENCFUNC = function(fn, _e, _d)
    return fn
end
07

LUNEX_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)()
Shim (development only)
getfenv().LUNEX_NO_VIRTUALIZE = function(...)
    return ...
end
08

LUNEX_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()
Shim (development only)
getfenv().LUNEX_NO_UPVALUES = function(...)
    return ...
end
09

LUNEX_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 = 47
10

Reserved 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  -- valid
11

Full 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
31end

Need help or have questions?