diff --git a/mods/CORE/Formspec/src/Formspec.lua b/mods/CORE/Formspec/src/Formspec.lua index 2d351cf..14de59f 100644 --- a/mods/CORE/Formspec/src/Formspec.lua +++ b/mods/CORE/Formspec/src/Formspec.lua @@ -197,12 +197,30 @@ end ---@return Formspec function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemIndex) local element = ('list[%s;%s;%s,%s;%s,%s;%s]'):format( - inventoryLocation, listName, x, y, w, h,startingItemIndex or '') + inventoryLocation, listName, x, y, w, h, startingItemIndex or '') self:addElement(element) return self end +---A wrapper around `Formspec:list` that allows access to the inventory of a node, +---specified by the coordinates of its position in the world. +---@param nodePos MapPosition +---@param listName string +---@param x number +---@param y number +---@param w number Are in inventory slots, not in coordinates. +---@param h number Are in inventory slots, not in coordinates. +---@param startingItemIndex number? The index of the first (upper-left) item to draw. Indices start at `0`. Default is `0`. +---@return Formspec +function Formspec:listNodeMetaLocation(nodePos, listName, x, y, w, h, startingItemIndex) + local inventoryLocation = ('nodemeta:%s,%s,%s'):format(nodePos.x, nodePos.y, nodePos.z) + + self:list(inventoryLocation, listName, x, y, w, h, startingItemIndex) + + return self +end + ---Creates and appends a list of `listring[;]` items based on the passed inventory list. --- ---**Elements:** `listring[;]` or `listring[]`