query · world.resource
Resource counts
Returns paginated detached world-wide totals for registered resources.
world.resource.counts(filters?, cursor?, page_size?) -> query-page
- Stable ID
world.resource.counts- Owner
- game.resource-economy
- Authority
- read_only
- Timing
- immediate
- Availability
- active-session
- Side effects
- none
- Determinism
- stable owner order at the current committed tick
- Introduced
- 1.0.0
Usage
Read bounded world-wide quantities in stable Resource order. Use display_name for player-facing labels and key or resource_id for durable logic. Use world.settlement.resources when an interface specifically claims to show one settlement's stores.
Parameters
- filters.resource_id: optional stable Resource identity.
- cursor: optional opaque continuation cursor returned by the same query.
- page_size: positive record limit capped by the host.
Returns
Detached world-wide resource rows with stable identity, authored key and display name, plus total, available, reserved, in-transit, consumed, and produced quantities.
Cost
Bounded by page size, the Resource owner count window, one content-catalog lookup per returned row, and the package query budget.
Fields
| ID | Type | Units | Required | Description |
|---|---|---|---|---|
available | unsigned-integer | resource-units | yes | Unreserved quantity. |
consumed | unsigned-integer | resource-units | yes | Cumulative consumed quantity. |
display_name | string | none | yes | Player-facing authored resource name. |
in_transit | unsigned-integer | resource-units | yes | Quantity in transit. |
key | string | none | yes | Authored resource key. |
produced | unsigned-integer | resource-units | yes | Cumulative produced quantity. |
reserved | unsigned-integer | resource-units | yes | Reserved quantity. |
resource_id | stable-id | none | yes | Resource identity. |
total | unsigned-integer | resource-units | yes | Current quantity in containers. |
Errors
error.capability-unavailableerror.invalid-queryerror.query-budget-exhaustederror.query-contract-violation
Examples
local result = world.query("world.resource.counts", {page_size = 16})
if result.status == "completed" then
for _, resource in ipairs(result.records) do
ui.row(resource.display_name, tostring(resource.total))
end
end
API history
- 1.0.0: Runtime contract published from the complete Phase 14 registry.
- 1.5.0: Added the authored display_name field for normal interface labels.
- 1.5.0: Clarified that totals cover the complete loaded Resource owner rather than one Settlement.
Related symbols
world.resourceworld.settlement.resourceserror.capability-unavailableerror.invalid-queryerror.query-budget-exhaustederror.query-contract-violationworld.query