Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

io.engine (procNode)

Call a function of the engine bridge on the CPU: reading an asset as a graph value, writing a value as an asset, reading scene entities as columns, and reading the scene's water.

Built from the Luau node (io.luau) over engine.module, which sits in this node's folder. core.entity.read, entity.transform, scene.water, sim.scene_colliders and io.export call it with the function they need; io.import calls engine.module through io.luau. Every function answers plain Luau tables: a column of values is a list of numbers, a list of { x, y, z[, w] } records, or { type = "String", values = { ... } }, which the caller hands to op.transfer.upload.

Inputs

  • fn (String, default "importAsset", one of "importAsset", "writeAsset", "countEntities", "readEntities", "importWater"). The bridge function to call. importAsset takes an AssetRef, as asset.resolve("<identity>", "<type>") writes one, and the options its type reads it with.
  • args (List<Value>, optional). The values the function is called with, in order.
  • returns (List<TypeName>, optional). The procgen types of the values the function returns, in order.
  • ceilingMs (Float, default 0, at least 0). The CPU time the function may run for, in milliseconds, counting the work it runs in any coroutine it resumes and in any task it starts while the call lasts; a call past it is refused. The time it waits on a frame, a program build, a read-back or a task, and the time its thread waits for a core on a busy machine, are not counted. 0 leaves the runtime's default ceiling.
  • live (String, default ""). The name of a bridge function that answers a digest of the state fn reads, such as readEntitiesLive for readEntities: the graph's live digest folds it in, so a Generator cooks the graph again when the scene state moves. Left empty, the call reads nothing the graph does not hold.

Outputs

  • value: what the called bridge function returned.
local read = g.io.engine({ fn = "importAsset", args = { asset.resolve("@builtin::meshes.cube", "mesh"), {} }, returns = { "Value", "Record" } })