What it does
engine_query
Resolves the engine-provided query globals the System Tools tabs read —
queryEntitiesTable, queryLogsTable, getProfilingDataTable, and the like.
The engine installs these on _G at boot (before the global table is sealed
read-only), so the tabs read them through this one indirection rather than each
touching _G directly.
The indirection is also the single override point: override / restore swap
a source for a stub or a mock/replay feed without writing the sealed _G.
resolve returns the override when one is set and otherwise falls through to
the live engine global.
Exports
M.resolve(name: string) -> function?— resolve a named engine query global, honouring any active override. Returns the override function if set, else the engine_Gglobal, elsenil.M.override(name: string, fn: function)— shadow an engine query global with a function until restored.M.restore(name: string)— clear an override soresolvefalls back to the engine global again.
Usage
local EngineQuery = require("@builtin::modules.api.editor.system_tools.engine_query")
local entities = EngineQuery.resolve("queryEntitiesTable")
-- Feed a mock during a test, then restore the live global:
EngineQuery.override("queryEntitiesTable", function() return mockRows end)
EngineQuery.restore("queryEntitiesTable")
Notes
- Overrides are module upvalues — they live for the VM lifetime and are shared by every tab that requires this module.
resolvereads the live_Gglobal viarawgeteach call, so an override is the only way to shadow it; the sealed_Gis never written.
Discussion
Scoped to this part · feeds back into the world's score.
Sign in to post.sign in
No comments yet. Be the first.