Always render weapons slot, even if empty

This commit is contained in:
Zughy 2023-07-20 21:37:18 +02:00
parent 12f48bc9fc
commit b67c12ebe3

View File

@ -30,19 +30,10 @@ function block_league.HUD_weapons_create(p_name)
-- armi
for i = 1, 3 do
local stack = inv:get_stack("main", i)
local item_name = stack:get_name()
local weapon = minetest.registered_nodes[item_name]
local w_name = inv:get_stack("main", i):get_name() ~= "" and inv:get_stack("main", i):get_name() or ("NIL" .. i)
local weapon = minetest.registered_nodes[w_name]
if weapon ~= nil then
sub_img_elems[item_name .. "_icon"] = {
scale = { x = 2, y = 2 },
offset = { x = offset_x, y = offset_y },
alignment = { x = -1, y = 1 },
text = weapon.inventory_image,
z_index = 1
}
sub_img_elems[item_name .. "_bg"] = {
sub_img_elems[w_name .. "_bg"] = {
scale = { x = 2, y = 2 },
offset = { x = offset_x, y = offset_y },
alignment = { x = 0, y = 1 },
@ -50,14 +41,24 @@ function block_league.HUD_weapons_create(p_name)
z_index = 0
}
sub_txt_elems[weapon.name .. "_magazine_txt"] = {
alignment = { x = 0, y = 1 },
offset = { x = offset_x + 30, y = offset_y + 6 },
text = weapon.magazine and weapon.magazine or "",
if weapon then
sub_img_elems[w_name .. "_icon"] = {
scale = { x = 2, y = 2 },
offset = { x = offset_x, y = offset_y },
alignment = { x = -1, y = 1 },
text = weapon.inventory_image,
z_index = 1
}
sub_txt_elems[w_name .. "_magazine_txt"] = {
alignment = { x = 0, y = 1 },
offset = { x = offset_x + 30, y = offset_y + 6 },
text = weapon.magazine or "",
z_index = 1
}
offset_x = offset_x + 90
end
offset_x = offset_x + 90
end
-- creo pannello