Data module

Tools for working with raw data.

Only usable in the mod data stage.

See also

Usage

local Data = require('stdlib/data/data')

Functions

select (pattern) Selects all data values where the key matches the selector pattern.

Functions

# select (pattern)

Selects all data values where the key matches the selector pattern.

The selector pattern is divided into groups. The pattern should have a colon character : to denote the selection for each group.

The first group is for the class of the data type (item, recipe, entity-type, etc).

The second group is for the name of the data element, and is optional. If missing, all elements matching prior groups are returned.

For more granular selectors, see other modules, such as Recipe.select.

Parameters:
  • pattern : (string) a pattern used for the search
Returns:
  • ({nil or Mixed,...}) an array containing the elements matching the selector pattern, or an empty array if there were no matches
Usage:
Data.select('recipe') -- returns an array with all recipes
Data.select('recipe:steel.*') -- returns an array with all recipes whose name matches 'steel.*'