Skip to main content

1.2.5

Date: 2026-05


Feature: auto-chunking for scalability

The problem

Lua limits each function to 200 local variable registers. The flat-compiled script runs as one function at runtime, so every top-level local declaration permanently consumes one slot. The Prometheus WrapInFunction obfuscation step adds an additional 10–15 on top.

At 31 modules, the standard build had 92 top-level locals — leaving 93 slots of headroom before the obfuscated build would crash at runtime with:

Out of local registers when trying to allocate W: exceeded limit 200

Adding ~30 more modules would have hit that wall.

What changed

Every .rblua component and UI page file is now compiled into its own immediately-invoked function expression (IIFE):

-- [src/combat/Aimbot.rblua]
(function()
local func = _G.__rb_func
-- ... transpiled component code
end)()

Each IIFE has its own 200-local budget that is independent of the outer script. Adding a new component file adds zero top-level locals to the outer function.

Plain .lua helper files (globals.lua, entities.lua, team.lua, etc.) remain flat — they need upvalue access to _LocalPlayer and to the func table as they build it up.

The compiler exports func to _G.__rb_func once, just before the first IIFE. Each component IIFE imports it back via local func = _G.__rb_func, so func.* calls work identically inside components with no source changes required.

Result

BeforeAfter
Top-level locals (31 modules)9244
Headroom before warn (160)68116
Headroom before abort (185)93141
Locals added per new .rblua file2–50

The script can now grow to hundreds of components without approaching the limit. The build-time guard (_LOCAL_WARN = 160, _LOCAL_ABORT = 185 in checker.py) remains active to catch any future regression from .lua helper growth.

No source changes required

Everything continues to work exactly as before:

  • Component signals, methods, and UI widgets are unaffected.
  • Cross-component references (Aimbot.enabled() from another component) still work — component names are globals registered via Component("Aimbot").
  • func.* helpers are available in all .rblua files under the same func variable name.
  • The rb build output is still a single .lua file.
  • Error reporting line numbers are correctly adjusted for the IIFE preamble.