Skip to content

API Queries

Piggo41 edited this page Oct 12, 2026 · 6 revisions

Queries

Lua API / Queries

Resource registry search methods are documented in References. Recipe searches have their own criteria.

On this page

Resource criteria

All specified filters must match. Missing criteria mean no filter.

local matches = betamoon.items:find {
    nameContains = "pickaxe",
    ignoreCase = true,
    where = function(item) return item.maxDamage > 100 end
}
Field Type Meaning
id integer Exact numeric ID.
damage integer or table Exact metadata, or inclusive { min = a, max = b } / { a, b } range. Omitted endpoints are unbounded.
name string Exact internal name comparison.
displayName string Exact translated display-name comparison.
nameContains string Substring in internal name.
ignoreCase boolean Case-insensitive text comparisons; default false.
type string Item type, compared case-insensitively.
owner string Owner comparison, case-insensitive.
where function(reference) Additional predicate; a truthy result includes the reference.

Result lists

Results contain references in numeric order, alongside the helper methods below.

results:first()

Returns the first element, or nil when empty.

local first = matches:first()

results:last()

Returns the last element, or nil when empty.

local last = matches:last()

results:one()

Returns the only element. Empty lists return nil; more than one element raises a Lua error.

local only = betamoon.blocks:find { id = 1 }:one()

results:isEmpty()

Returns a boolean indicating whether the list contains zero results.

if matches:isEmpty() then return end

results:overrideAll(definition)

Applies one override definition to each reference and returns a one-based list of individual override handles. Each target is processed separately; this is not an atomic transaction. A non-table definition is an error.

local handles = betamoon.blocks:find { id = 3 }:overrideAll {
    displayName = "Garden Dirt"
}

See Overrides for conditions and handle removal.

Examples: Block queries, item queries.

Clone this wiki locally