diff --git a/block_league/src/HUD/hud_weapons.lua b/block_league/src/HUD/hud_weapons.lua index fae74a8..1689099 100644 --- a/block_league/src/HUD/hud_weapons.lua +++ b/block_league/src/HUD/hud_weapons.lua @@ -30,34 +30,35 @@ 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"] = { + sub_img_elems[w_name .. "_bg"] = { + scale = { x = 2, y = 2 }, + offset = { x = offset_x, y = offset_y }, + alignment = { x = 0, y = 1 }, + text = "bl_hud_bullets_bg.png", + z_index = 0 + } + + 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_img_elems[item_name .. "_bg"] = { - scale = { x = 2, y = 2 }, - offset = { x = offset_x, y = offset_y }, - alignment = { x = 0, y = 1 }, - text = "bl_hud_bullets_bg.png", - 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 "", - 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