util.export.list

Shared

Retrieves all export names registered by a resource


Syntax

local result = util.export.list(
    resource
)

The target resource must be running before listing its exports.

Throws an error if the specified resource is not currently running. Use this function to inspect or validate available export before calling them.

Parameters

TypeNameDescription
stringresourceName of the resource whose export to list

Returns

TypeNameDescription
tableresultArray of export name strings registered by the resource; empty table if none are registered

Examples

List all export from a resource
core.engine.iprint(util.export.list("my_resource"))
Check whether a specific export exists before calling it
local list = util.export.list("inventory_resource")

local has_export = false
for _, name in ipairs(list) do
    if name == "get_items" then
        has_export = true
        break
    end
end

if has_export then
    local items = util.export.call("inventory_resource", "get_items", player_id)
    core.engine.iprint(items)
else
    core.engine.print("warn", "Export 'get_items' not found on inventory_resource")
end

On this page