util.export.call

Shared

Calls an exported function from another resource


Syntax

local ... = util.export.call(
    resource,
    name,
    ...
)

The target resource must be running before calling its export.

  • Resource state — throws an error if the specified resource is not currently running.
  • Export existence — throws an error if the named export does not exist on that resource.
  • Error propagation — if the exported function itself throws, the error is re-raised at the call site in the calling resource.

Parameters

TypeNameDescription
stringresourceName of the resource that owns the export
stringnameName of the export to invoke
any...Arguments forwarded to the exported function

Returns

TypeNameDescription
any...All values returned by the exported function, forwarded as-is

Examples

Call a basic export from another resource
local count = util.export.call("my_resource", "get_player_count")

core.engine.print("info", "Player count:", count)
Pass arguments to an export
local result = util.export.call("math_resource", "add", 10, 25)

core.engine.print("info", "Sum:", result) -- 35
Capture multiple return values
local x, y, z = util.export.call("world_resource", "get_spawn_position")

core.engine.print("info", "Spawn:", x, y, z)

On this page