From d82cd28407872072706c60dabe0e3e9d658426bc Mon Sep 17 00:00:00 2001 From: varttist Date: Sun, 4 Oct 2026 22:27:47 +0300 Subject: [PATCH] `Formspec`: new method `imageButtonRow` --- mods/CORE/Formspec/src/Formspec.lua | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/mods/CORE/Formspec/src/Formspec.lua b/mods/CORE/Formspec/src/Formspec.lua index 12c7287..895df95 100644 --- a/mods/CORE/Formspec/src/Formspec.lua +++ b/mods/CORE/Formspec/src/Formspec.lua @@ -745,6 +745,41 @@ function Formspec:imageButton(x, y, w, h, textureName, name, label, pressedTextu return self end +---@alias Formspec.ImageButtonRowElement { +--- [1] : string, +--- [2] : string, +--- [3] : string?, +--- [4] : string?, +--- [5] : boolean?, +--- [6] : boolean?, +--- } + +---Creates a row of buttons, automatically calculating the coordinates of buttons based on the width. +--- +---@see Formspec.imageButton +---@param x number +---@param y number +---@param w number +---@param h number +---@param imageButtonRow Formspec.ImageButtonRowElement[] +---@return Formspec +function Formspec:imageButtonRow(x, y, w, h, imageButtonRow) + ---@param element Formspec.ImageButtonRowElement + for i, element in ipairs(imageButtonRow) do + local ex = x + ( ( i - 1 ) * w) + self:imageButton(ex, y, w, h, + element[1], + element[2], + element[3], + element[4], + element[5], + element[6] + ) + end + + return self +end + ---Clickable item image button. When clicked, fields will be sent. --- ---**Element:** `item_image_button[,;,;;;