From 82cdf24045ecb6821876e77b6d3e42aec590c9c9 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Sat, 31 Dec 2022 09:43:46 +1300 Subject: [PATCH] Improve scroll height calculation (#220) --- internal.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal.lua b/internal.lua index 7231969..45db6b3 100644 --- a/internal.lua +++ b/internal.lua @@ -91,9 +91,10 @@ local function formspec_tab_buttons(player, formspec, style) end formspec[n] = "scroll_container_end[]" if needs_scrollbar then + local total_rows = math.ceil(#filtered_inv_buttons / style.main_button_cols) formspec[n+1] = ("scrollbaroptions[max=%i;arrows=hide]"):format( -- This calculation is not 100% accurate but "good enough" - math.ceil((#filtered_inv_buttons - 1) / style.main_button_cols) * style.btn_spc * 5 + (total_rows - style.main_button_rows) * style.btn_spc * 10 ) formspec[n+2] = ("scrollbar[%g,%g;0.4,%g;vertical;tabbtnscroll;0]"):format( style.main_button_x + style.main_button_cols * style.btn_spc - 0.1, -- x pos