From 97172b6f0ff2195105594204318eea00cc5915e9 Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Wed, 12 Jan 2022 21:16:20 +0100 Subject: [PATCH] sfinv_button: fix issues with Buttons in last row --- sfinv_buttons/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sfinv_buttons/init.lua b/sfinv_buttons/init.lua index 29ad920..72c5d67 100644 --- a/sfinv_buttons/init.lua +++ b/sfinv_buttons/init.lua @@ -42,14 +42,14 @@ smart_sfinv_api.register_enhancement({ return end - handler.formspec_size_add_w = handler.formspec_size_add_w + math.floor(last_button / sfinv_buttons.MAX_ROWS) + 1 + handler.formspec_size_add_w = handler.formspec_size_add_w + math.floor((last_button - 1) / sfinv_buttons.MAX_ROWS) + 1 local retval = "" for idx = 1, last_button do local def = sfinv_buttons.registered_buttons[idx] - local x = 8.1 + math.floor(idx / sfinv_buttons.MAX_ROWS) + local x = 8.1 + math.floor((idx - 1)/ sfinv_buttons.MAX_ROWS) local y = (idx - 1) % sfinv_buttons.MAX_ROWS if def and (def.show == nil or def.show == true or def.show(player, context, content, show_inv) == true) then