From bd5a42356bc20a71dac5d11ea04deb4fa6246d0e Mon Sep 17 00:00:00 2001 From: Awkanimus <119243140+Awkanimus@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:44:41 -0500 Subject: [PATCH] Use sane default i3 inventory settings when missing (#57) - i3.settings.hotbar_len and i3.settings.inv_size were removed in commit 75fddf7 because they are now per-player settings - This just uses sane defaults when the settings are not present to avoid a few nils and allow the game to continue --- common.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common.lua b/common.lua index 4746906..1161ba6 100644 --- a/common.lua +++ b/common.lua @@ -149,7 +149,8 @@ function fs_helpers.get_inv(y) local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22 local inv_y = (y + 0.4) or 6.9 local size, spacing = 1, 0.1 - local hotbar_len = i3.settings.hotbar_len + local hotbar_len = i3.settings.hotbar_len or (i3.settings.legacy_inventory and 8 or 9) + local inv_size = i3.settings.inv_size or (hotbar_len * 4) table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]") @@ -162,13 +163,13 @@ function fs_helpers.get_inv(y) table.insert(fs, "style_type[box;colors=#666]") for i=0, 2 do - for j=0, (i3.settings.legacy_inventory and 7 or 8) do + for j=0, hotbar_len - 1 do table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]") end end table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]") - table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(i3.settings.inv_size / hotbar_len)..";"..hotbar_len.."]") + table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(inv_size / hotbar_len)..";"..hotbar_len.."]") else table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]") end