execute
A Luau REPL dock panel for the System Tools dock. The user types a Luau chunk into the input box and runs it; each run becomes a scrollback entry showing the source, any print output captured during the run, and the serialized return value (or the compile / runtime error, rendered in an error colour).
The REPL core is loadstring(code) then pcall(chunk). print output is captured by giving the chunk a private environment via setfenv whose print appends to a per-run buffer while every other global falls through to _G, so the chunk sees the full engine API. Tables in the return value are serialized with the json module; everything else uses tostring. History lives under state.execute (the dock host state), survives closing and reopening the panel within a session, and is capped at ~100 entries.
Exports
M.label— the dock tab label ("Execute").M.run(state, code) -> entry— run a Luau chunk through the REPL and append the result to scrollback. Returns the entry{ input, prints, output, isError }, so callers (including tests) can assert on it.M.build(state) -> widget— build the Execute tab widget tree (aZ.panel).M.onCallback(callbackId, data, state) -> boolean— handle a widget callback (input change, run, clear). Returnstruewhen consumed.
The host calls M.build on markDirty and M.onCallback on widget events; there is no refresh (the panel only changes when the user runs something).
Usage
local Execute = require("modules.api.editor.system_tools.tabs.execute")
local e = Execute.run(state, "return 1 + 1")
Scoped to this part · feeds back into the world's score.