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
| Type | Name | Description |
|---|---|---|
string | resource | Name of the resource that owns the export |
string | name | Name of the export to invoke |
any | ... | Arguments forwarded to the exported function |
Returns
| Type | Name | Description |
|---|---|---|
any | ... | All values returned by the exported function, forwarded as-is |
Examples
local count = util.export.call("my_resource", "get_player_count")
core.engine.print("info", "Player count:", count)local result = util.export.call("math_resource", "add", 10, 25)
core.engine.print("info", "Sum:", result) -- 35local x, y, z = util.export.call("world_resource", "get_spawn_position")
core.engine.print("info", "Spawn:", x, y, z)