From 6dba6f8c78126ce1bef95bfd01547f54c826ef24 Mon Sep 17 00:00:00 2001 From: Vanic Date: Thu, 16 Apr 2026 21:07:19 +0300 Subject: [PATCH] `PlayerInventory` & `PlayerInventoryUI`: create equip slots & draft equip tab. #34 --- mods/CORE/Player/src/Player.lua | 5 +++++ .../src/PlayerInventoryUI.lua | 4 ++-- .../src/PlayerInventoryUI/getEquipTab.lua | 13 +++++++++++-- .../player_inventory_equip_tab_background.png | Bin 0 -> 101860 bytes 4 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 mods/UI/PlayerInventoryUI/textures/player_inventory_equip_tab_background.png diff --git a/mods/CORE/Player/src/Player.lua b/mods/CORE/Player/src/Player.lua index c415c0a..5eae71e 100644 --- a/mods/CORE/Player/src/Player.lua +++ b/mods/CORE/Player/src/Player.lua @@ -9,6 +9,11 @@ core.register_on_joinplayer(function(player) player:hud_set_hotbar_itemcount(9) local inv = player:get_inventory() inv:set_size('main', 18) + -- Player equipment slots: + inv:set_size('equip_head', 2) + inv:set_size('equip_torso', 2) + inv:set_size('equip_legs', 2) + inv:set_size('equip_feet', 2) end) core.register_chatcommand('show_inv', diff --git a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua index 9d4275d..77e16c8 100644 --- a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua +++ b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI.lua @@ -117,7 +117,7 @@ local function getFullForm(self, playerName) -- * left tab - equipment; -- * right tab - crafting menu. ---@type PlayerInventoryUI.TabName - local leftTabName = self:getContex(playerName, 'left_tab_name') or 'craft_tab' + local leftTabName = self:getContex(playerName, 'left_tab_name') or 'equip_tab' ---@type PlayerInventoryUI.TabName local rightTabName = self:getContex(playerName, 'right_tab_name') or 'craft_tab' @@ -141,7 +141,7 @@ local function getFullForm(self, playerName) -- Removing the inventory background color: :bgcolor('#00000000', 'neither') -- A permanent part of the inventory: - :background(0, 9.5, 22, 3, 'player_inventory_middle_backgound.png', false) + :background(0, 9.5, 22, 3, 'player_inventory_middle_background.png', false) :listColors('#00000000', '#e1b69150') :list('current_player', 'main', 5.5,9.75, 9,1) :list('current_player', 'main', 5.5,11.25, 9,1, 9) diff --git a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getEquipTab.lua b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getEquipTab.lua index aa67309..684c003 100644 --- a/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getEquipTab.lua +++ b/mods/UI/PlayerInventoryUI/src/PlayerInventoryUI/getEquipTab.lua @@ -7,9 +7,18 @@ local Formspec = Smc.requireFormspec() local function getEquipTab(self, playerName, tabType) local EquipTab = Formspec:new() + ---The x coordinate for the equipment slot position + local equipListsX = 4.5 + EquipTab - :image(0, 0, 11, 9, 'player_inventory_tab_background.png') - :label(2,2, 'EQUIPMENT PANE') + :image(0, 0, 11, 9, 'player_inventory_equip_tab_background.png') + -- Equipment slots: + :label(equipListsX, 0.75, 'cloth') + :label(equipListsX+1.25, 0.75, 'armor') + :list('current_player', 'equip_head', equipListsX, 1, 2, 1) + :list('current_player', 'equip_torso', equipListsX, 2.25, 2, 1) + :list('current_player', 'equip_legs', equipListsX, 3.5, 2, 1) + :list('current_player', 'equip_feet', equipListsX, 4.75, 2, 1) return EquipTab end diff --git a/mods/UI/PlayerInventoryUI/textures/player_inventory_equip_tab_background.png b/mods/UI/PlayerInventoryUI/textures/player_inventory_equip_tab_background.png new file mode 100644 index 0000000000000000000000000000000000000000..9973b6d167687829d2032a0874d182ce6194f491 GIT binary patch literal 101860 zcmeI4PiP%Q9LML`Xk(jz>7lg|F;Gy%P$k%de?U@Gns-Rh&`a@B^`HonLRE@j+K3he z!6+U)6g*YbgDB|5dKATq!6+Ccct{H|&83GRiU{>h%Ou;)d-G=B&dmPa?x*njc4vO` zo9}#n-)#0Jvw7=@$;16S26rf>`s?FkQ;qk}8?U+ETN?j=e8=+hjknr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