Update MetaDataRef & readme, rename readme and license
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
---Version: 5.16
|
||||
---@meta
|
||||
|
||||
---Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`],
|
||||
@@ -70,24 +71,75 @@ function MetaDataRef:set_float(key, value) end
|
||||
---@return number
|
||||
function MetaDataRef:get_float(key) end
|
||||
|
||||
--- Returns a list of all keys in the metadata.
|
||||
--- @return table
|
||||
---Returns a list of all keys in the metadata.
|
||||
---@return table
|
||||
function MetaDataRef:get_keys() end
|
||||
|
||||
--- returns `nil` or a table with keys:
|
||||
--- * `fields`: key-value storage
|
||||
--- * `inventory`: `{list1 = {}, ...}}` (NodeMetaRef only)
|
||||
--- @return table|nil
|
||||
---Metadata tables represent MetaDataRef in a Lua table form (see `from_table`/`to_table`).
|
||||
---
|
||||
---Example:
|
||||
---```lua
|
||||
---metadata_table = {
|
||||
--- -- metadata fields (key/value store)
|
||||
--- fields = {
|
||||
--- infotext = "Container",
|
||||
--- another_key = "Another Value",
|
||||
--- },
|
||||
--- -- inventory data (for nodes)
|
||||
--- inventory = {
|
||||
--- -- inventory list "main" with 4 slots
|
||||
--- main = {
|
||||
--- -- list of all item slots
|
||||
--- [1] = ItemStack("example:dirt"),
|
||||
--- [2] = ItemStack("example:stone 25"),
|
||||
--- [3] = ItemStack(""), -- empty slot
|
||||
--- [4] = ItemStack("example:pickaxe"),
|
||||
--- },
|
||||
--- -- inventory list "hidden" with 1 slot
|
||||
--- hidden = {
|
||||
--- [1] = ItemStack("example:diamond"),
|
||||
--- },
|
||||
--- },
|
||||
---}
|
||||
---```
|
||||
---@class MetaDataRef.Table
|
||||
---Key-value storage of metadata fields.
|
||||
---
|
||||
---All values are stored as strings.
|
||||
---
|
||||
---Numbers must be converted to strings first.
|
||||
---@field fields table
|
||||
---
|
||||
---(for NodeMetaRef only): A node inventory in table form
|
||||
---
|
||||
---Inventory table keys are inventory list names.
|
||||
---
|
||||
---Inventory table values are item tables.
|
||||
---
|
||||
---Item table keys are slot IDs (starting with 1).
|
||||
---
|
||||
---Item table values are ItemStacks
|
||||
---@field inventory table
|
||||
|
||||
---Returns a [metadata table](lua://MetaDataRef.Table) or `nil` on failure.
|
||||
---@return MetaDataRef.Table?
|
||||
function MetaDataRef:to_table() end
|
||||
|
||||
--- * Any non-table value will clear the metadata
|
||||
--- * See [Node Metadata] for an example
|
||||
--- * returns `true` on success
|
||||
--- @param value table|nil
|
||||
--- @return boolean
|
||||
function MetaDataRef:from_table(value) end
|
||||
---Imports metadata from a [metadata table](lua://MetaDataRef.Table).
|
||||
---
|
||||
---If `data` is a metadata table,
|
||||
---the metadata it represents will replace all metadata of this MetaDataRef object.
|
||||
---
|
||||
---Any non-table value for `data` will clear all metadata.
|
||||
---
|
||||
---Item table values the inventory field may also be itemstrings.
|
||||
---
|
||||
---Returns `true` on success.
|
||||
--- @param data MetaDataRef.Table?
|
||||
--- @return boolean
|
||||
function MetaDataRef:from_table(data) end
|
||||
|
||||
--- * returns `true` if this metadata has the same key-value pairs as `other`
|
||||
--- @param other any
|
||||
--- @return boolean
|
||||
---Returns `true` if this metadata has the same key-value pairs as `other`.
|
||||
---@param other any
|
||||
---@return boolean
|
||||
function MetaDataRef:equals(other) end
|
||||
|
||||
Reference in New Issue
Block a user