diff --git a/mods/CORE/Formspec/src/Formspec.lua b/mods/CORE/Formspec/src/Formspec.lua index da6ca9f..0add3e8 100644 --- a/mods/CORE/Formspec/src/Formspec.lua +++ b/mods/CORE/Formspec/src/Formspec.lua @@ -1,3 +1,6 @@ +local tableConcat, tableKeyValueList, tableInsert + = table.concat, table.key_value_list, table.insert + local getInstance = Class.getInstance ---@class Formspec @@ -107,25 +110,26 @@ function Formspec:new(def) return instance end ----TODO: описание +---Returns a string specifying the form parameters: +---`version`, `size`, `position`, `anchor`, `padding`, `no_prepend`, `real_coordinates`, `allowClose`. ---@return string function Formspec:getParams() return self.params end ----TODO: описание +---Returns a string containing all elements registered in the form. ---@return string function Formspec:getElements() return self.elements end ----TODO: описание +---Returns a formspec string that is a form definition for Luanti. ---@return string function Formspec:toString() return self:getParams()..self:getElements() end ----TODO: описание +---Adds an element to the list of form elements. ---@param element string function Formspec:addElement(element) self.elements = self.elements..element @@ -144,7 +148,7 @@ function Formspec:container(container, x, y) self:addElement(element) end ----Start of a scroll_container block. All contained elements will +---Create scroll_container block. All contained elements will ---take the scroll_container coordinate as position origin, ---be additionally moved by the current value of the scrollbar with ---the name `scrollbar name` times `scroll factor` along the orientation `orientation` and @@ -159,7 +163,8 @@ end ---@param scrollbarName string ---@param orientation 'vertical'|'horizontal' ---@param scrollFactor number? Defaults to 0.1. ----@param contentPadding string? TODO: разобраться, что тут +---@param contentPadding number? In formspec coordinate units. If specified, the scrollbar properties `max` and `thumbsize` are calculated +--- automatically based on the content size plus `content padding` at the end of the container. `min` is set to `0`. function Formspec:scrollContainer(container, x, y, w, h, scrollbarName, orientation, scrollFactor, contentPadding) local element = ('scroll_container[%s,%s;%s,%s;%s;%s;%s;%s]'):format( x, y, w, h, scrollbarName, orientation, scrollFactor or '', contentPadding or '').. @@ -192,10 +197,10 @@ function Formspec:list(inventoryLocation, listName, x, y, w, h, startingItemInde self:addElement(element) end ----TODO: немного отличается от листринга луанти, так что надо дописать подробности +---Creates and appends a list of `listring[;]` items based on the passed inventory list. --- ---**Elements:** `listring[;]` or `listring[]` ----@param lists [string, string][]? List of looping lists in the format `[inventory location, list name]` +---@param lists [string, string][]? List of looping lists in the format `[inventory location, list name]`. If `nil`, it will be added `listring[]`. function Formspec:listring(lists) if lists == nil then self:addElement('listring[]') @@ -668,7 +673,7 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu self:addElement(element) end ----TODO: описание +---Clickable item image button. When clicked, fields will be sent. --- ---**Element:** `item_image_button[,;,;;;