From 83d9074e069bc6b571298b1f75665896753ebcce Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Fri, 12 Jan 2024 03:39:30 -0600 Subject: [PATCH] Show/hide footer_button with access() function Now those with this function defined can be hidden. --- src/gui.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui.lua b/src/gui.lua index 5b9bf2c..dd7cdab 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -694,13 +694,17 @@ end -- Get the inventory-footer’s formspec. local function get_footer(fs, data, player) -- Render individual footer buttons. + local i = 1 local starting_x = 3.43 - (.3 * (#i4.footer_buttons - 4)) -- Center the icons - for i, btn in ipairs(i4.footer_buttons) do - local btn_name = "footer_" .. btn.name - fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]", - btn_name, btn.image, btn.image) - 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) + for _, btn in ipairs(i4.footer_buttons) do + if not btn.access or btn.access(player, data) then + local btn_name = "footer_" .. btn.name + fs("style[%s;fgimg=%s;fgimg_hovered=%s^\\[brighten^\\[colorize:#fff:100;content_offset=0]", + btn_name, btn.image, btn.image) + 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 -- Render the current-selected button’s formspec, if one is active.