Running scripts
Execute and Clear VM
-
Open a script in the Lua tab and press Execute. The editor text is executed as is, it does not need to be saved first.
-
There is one VM. Each Execute runs the code inside it: globals, listeners, receivers and signals of earlier executions stay alive and keep running. An execution that fails prints its error and leaves the VM running.
-
Clear VM calls
on_unloadand theunloadsignal, then destroys the VM: every global, listener, receiver, signal, image and packet block of every execution is gone. The next Execute starts a fresh VM. -
require("name")looks forname.luaandname/init.luainC:\xiaohook\luaonly (a.bmeansa/b.lua).package.pathandpackage.cpathare ignored and native modules cannot be loaded. -
Scripts run in a sandbox: the only disk access is
xiao.fs, limited toC:\xiaohook(see Sandbox).
Editor
Ctrl+C,Ctrl+X,Ctrl+Vuse the Windows clipboard. Without a selection, copy and cut take the whole line.Ctrl+Zundo,Ctrl+YorCtrl+Shift+Zredo,Ctrl+Aselect all,Ctrl+Ssave,Ctrl+/toggle comment.- While the editor has the focus, key presses do not reach the game.
Console
Execute opens the console window. It floats over the game while the menu is open:
- drag its header to move it, drag its edges to resize it
- Clear empties it, the cross closes it
- it opens again on the next Execute
print(...) writes to the console, arguments are separated by tabs. Errors are shown in red with the file name, the
line and a stack traceback.
Time limits
The limit also applies to loops already compiled by the JIT. A timeout cannot be caught with pcall or xpcall.
Lifecycle callbacks
on_frame is a single global: the last execution that defines it wins. An error in on_frame removes it
(on_frame removed: ... in the console). An error in a paint listener, a packet receiver or a signal callback fired by
the client only removes that callback.
The signals think and unload (see xiao.signal) are the preferred way to hook these events, because
several executions can each add their own callback.
Order of one frame:
- packet receivers, for every packet captured since the last frame
on_frame(dt)- the
thinksignal - the paint listeners