Blockman GO Lua eXecutor
bglx is a Lua runtime and packer for Blockman GO engine2 games. It loads your scripts inside a game package and gives them a stable set of bindings for keys, timers, events, packets and the engine GUI.
The core never checks for a game id. It talks to the engine2 globals (World,
Lib, Me, Player, GUIWindowManager, GUISystem) and works across engine2
games. The test fixtures happen to be Anime All Star (g2041) and Anime Fighting
Simulator (g2033), but the runtime does not depend on either.
Unofficial. Not affiliated with Sandboxol or Blockman GO. Use at your own risk.
- Author: quefep
- Discord: https://discord.gg/KWumB8hkBp
- License: MIT with attribution, see LICENSE and NOTICE
This is a working base layer. The packer and runtime are tested against real engine2 packages in a headless host. A live room test on a phone is still open, so treat the first install as a test install.
Working:
- plugin mode, loaded by
common/plugin_manager.luabefore the game'slua/main.lua - client mode, using the
lua/client/<name>/init.luaslot that CeriumCore demonstrated - script loading, keys, toggles, actions, timers, named events, method hooks
- lazy outgoing packet taps on
Player.sendPacket - a small panel built from whatever scripts registered
- inject, verify, list and eject in the Python packer
- checksum updates for every file bglx adds
Not included:
- no built-in gameplay cheats
- no native or kernel hooks
- no promise that a modified archive passes every anti-cheat build
Requires Python 3.9+.
git clone https://github.com/quefeps/bglx
cd bglx
python3 -m pip install -e .If bglx is not on your PATH, use python3 -m bglx instead.
Inject one script:
bglx inject g2041.zip -o g2041-bglx.zip --script my-script.luaOr inject a folder. All *.lua files in it are added in name order:
bglx inject g2041.zip -o g2041-bglx.zip --script premade/g2041Copy the output over the game archive. Keep the original.
/sdcard/Android/data/com.sandboxol.blockymods.channel.official/files/Download/SandboxOL/BlockManv2/map_temp/g2041/g2041.zip
Some installs use com.sandboxol.blockymods without .channel.official. The
folder name and the zip name must match the game id.
Enter the room again. A bglx button appears in the top right. Tap it to open
the panel. Use --no-menu if you want the scripts without a visible panel.
--mode plugin is the default. The packer writes:
plugin/bglx/lua/main.lua
plugin/bglx/lua/client/bglx/init.lua
plugin/bglx/lua/client/bglx/core.lua
plugin/bglx/lua/client/bglx/scripts/<name>.lua
common/plugin_manager.lua in the engine tree scans plugin/ and loads
plugin/<name>/lua/main.lua before it loads the game's lua/main.lua. The
server runs the same scan, so the entry returns immediately when
World.isClient is false.
--mode client writes the older layout:
lua/client/bglx/init.lua
lua/client/bglx/...
This exists for map packages that load lua/client/<name>/init.lua. Plugin mode
is the default because it follows the engine source.
Neither mode edits lua/main.lua or lua/script_client/main.lua. That matters
when the entries are Lua 5.3 bytecode.
A script is a normal Lua file. The global bglx exists before it runs.
bglx.ready(function()
bglx.log("loaded on %s", bglx.game)
end)
bglx.toggle("key.f1", "Fly", function(on)
-- game call here
end)
bglx.action("key.f2", "Heal", function()
bglx.send({ pid = "SomePacket" })
end)
local tick = bglx.every(1000, function()
bglx.log("tick")
end)Engine2 puts a strict metatable on _G. Assigning a new global from a script
throws. Use locals. If you really need a global, use rawset(_G, "name", value).
The API is documented in docs/API.md. The short version:
| Call | Purpose |
|---|---|
bglx.ready(fn) |
run when World, Lib, Me and Me.sendPacket exist |
bglx.after(ms, fn) / bglx.every(ms, fn) |
timers with real cancellation |
bglx.key(name, fn) |
raw key bind |
bglx.toggle(name, label, fn, opts) |
state, key bind and panel row |
bglx.action(name, label, fn, opts) |
action row and optional key bind |
bglx.on(name, fn) / bglx.emit(name, ...) |
named events |
bglx.hook(table, "method", fn) |
wrap a method, with restore() |
bglx.on_send(fn) |
tap outgoing packets while the listener exists |
bglx.send(packet, resp) |
guarded Me:sendPacket |
bglx.script(source, name) |
compile and run a chunk now |
bglx.log(...) |
quiet in-memory log |
The core stays engine2-wide. Game-specific scripts go in premade/<game>/.
That folder is optional. Nothing in the runtime reads it.
premade/
README.md
template/
init.lua
Copy premade/template to premade/g2041 or another game id, then inject the
folder:
bglx inject g2041.zip -o g2041-bglx.zip --script premade/g2041Keep game-specific ids, packet names and GUI asset paths in premade/<game>/.
Do not put them in core.lua.
With no packet scripts:
- no edits to
lua/main.luaorlua/script_client/main.lua - no
package.pathchanges in plugin mode - no
io.openreplacement - no logcat output and no
printoutput - no
Player.sendPacketwrapper - checksum entries for every added file
Plugin mode adds one line to the engine log because
common/plugin_manager.lua prints a line for each plugin it loads.
BGLX_LUA=/path/to/lua5.3 python3 -m unittest discover -s tests -vThe suite covers:
- packer inject, verify, list, eject and re-inject
- plugin and client layouts on a real g2041 package
- plugin layout on a real g2033 package
- a headless g2041 host with the engine2 strict
_G - keys, timers, packet taps, hooks, events and the panel
You can run the Lua part alone:
/path/to/lua5.3 tests/test_runtime.lua .bglx/ Python packer
bglx/runtime/client/ Lua runtime copied into the game zip
premade/ optional game-specific scripts
examples/ small engine2-wide examples
tests/ Python tests, Lua tests, g2041 host
docs/ API, engine notes, detection notes
CeriumCore by LuniEclipse showed that the lua/client/<name>/init.lua slot is
usable on engine2. The client mode follows that idea. No CeriumCore code is
included.
The engine2 plugin load order, strict _G, timer signatures and packet shape
come from the decompiled 3.33.1 engine tree in the local research workspace.
The runtime and packer are written for this project.
MIT. You can use, modify and redistribute bglx, including commercially. Any redistribution or derivative must keep the copyright notice and the MIT permission notice, and must credit quefep as the original author. See LICENSE and NOTICE.