Show/hide footer_button with access() function

Now those with this function defined can be hidden.
This commit is contained in:
Jaidyn Ann 2024-01-12 03:39:30 -06:00
parent 4f0b41b61f
commit 83d9074e06

View File

@ -694,13 +694,17 @@ end
-- Get the inventory-footers formspec. -- Get the inventory-footers formspec.
local function get_footer(fs, data, player) local function get_footer(fs, data, player)
-- Render individual footer buttons. -- Render individual footer buttons.
local i = 1
local starting_x = 3.43 - (.3 * (#i4.footer_buttons - 4)) -- Center the icons local starting_x = 3.43 - (.3 * (#i4.footer_buttons - 4)) -- Center the icons
for i, btn in ipairs(i4.footer_buttons) do for _, btn in ipairs(i4.footer_buttons) do
local btn_name = "footer_" .. btn.name if not btn.access or btn.access(player, data) then
fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]", local btn_name = "footer_" .. btn.name
btn_name, btn.image, btn.image) fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]",
image_button(i + starting_x - (i * 0.4), 11.43, 0.35, 0.35, "", btn_name, "") btn_name, btn.image, btn.image)
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, btn.description) image_button(i + starting_x - (i * 0.4), 11.43, 0.35, 0.35, "", btn_name, "")
fs("tooltip[%s;%s;#32333899;#fff]", btn_name, btn.description)
i++
end
end end
-- Render the current-selected buttons formspec, if one is active. -- Render the current-selected buttons formspec, if one is active.