🚀 Redesign the armor tab (preview: https://i.imgur.com/Ulkx6KB.png)
This commit is contained in:
parent
aa10460886
commit
7e7422def7
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -6,7 +6,7 @@ local init_hud = i3.files.hud()
|
|||
local set_fs = i3.set_fs
|
||||
|
||||
IMPORT("slz", "min", "insert", "copy", "ItemStack")
|
||||
IMPORT("spawn_item", "reset_data", "get_detached_inv")
|
||||
IMPORT("spawn_item", "reset_data", "get_detached_inv", "play_sound")
|
||||
|
||||
core.register_on_player_hpchange(function(player, hpchange)
|
||||
local name = player:get_player_name()
|
||||
|
@ -66,16 +66,88 @@ core.register_on_player_inventory_action(function(player, _, _, info)
|
|||
end
|
||||
end)
|
||||
|
||||
if core.global_exists("armor") then
|
||||
if core.global_exists"armor" then
|
||||
i3.modules.armor = true
|
||||
armor:register_on_update(set_fs)
|
||||
|
||||
local group_indexes = {
|
||||
{"armor_head", "i3_heavy_helmet"},
|
||||
{"armor_torso", "i3_heavy_armor"},
|
||||
{"armor_legs", "i3_heavy_leggings"},
|
||||
{"armor_feet", "i3_heavy_boots"},
|
||||
{"armor_shield", "i3_heavy_shield"},
|
||||
}
|
||||
|
||||
local function check_group(def, group)
|
||||
return def.groups[group] and def.groups[group] > 0
|
||||
end
|
||||
|
||||
armor:register_on_equip(function(player, idx, stack)
|
||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||
local def = stack:get_definition()
|
||||
local name = player:get_player_name()
|
||||
local data = i3.data[name]
|
||||
|
||||
for i, v in ipairs(group_indexes) do
|
||||
local group, sound = unpack(v)
|
||||
local stackname = stack:get_name()
|
||||
|
||||
if stackname:find"wood" or stackname:find"stone" or stackname:find"cactus" then
|
||||
sound = sound:gsub("heavy", "light")
|
||||
end
|
||||
|
||||
if i == idx and check_group(def, group) then
|
||||
data.armor_allow = sound
|
||||
return armor:register_on_update(set_fs)
|
||||
end
|
||||
end
|
||||
|
||||
data.armor_disallow = true
|
||||
armor_inv:remove_item("armor", stack)
|
||||
end)
|
||||
|
||||
armor:register_on_update(function(player)
|
||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||
if not armor_inv then return end
|
||||
|
||||
for i = 1, 5 do
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
local def = stack:get_definition()
|
||||
|
||||
for j, v in ipairs(group_indexes) do
|
||||
local group = v[1]
|
||||
|
||||
if check_group(def, group) and i ~= j then
|
||||
armor_inv:set_stack("armor", i, armor_inv:get_stack("armor", j))
|
||||
armor_inv:set_stack("armor", j, stack)
|
||||
return play_sound(name, "i3_cannot", 0.8)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
core.register_on_player_inventory_action(function(player, action, _, info)
|
||||
if action ~= "take" then return end
|
||||
local name = player:get_player_name()
|
||||
local data = i3.data[name]
|
||||
|
||||
if data.armor_disallow then
|
||||
local inv = player:get_inventory()
|
||||
inv:set_stack("main", info.index, info.stack)
|
||||
data.armor_disallow = nil
|
||||
play_sound(name, "i3_cannot", 0.8)
|
||||
|
||||
elseif data.armor_allow then
|
||||
play_sound(name, data.armor_allow, 0.8)
|
||||
data.armor_allow = nil
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
if core.global_exists("skins") then
|
||||
if core.global_exists"skins" then
|
||||
i3.modules.skins = true
|
||||
end
|
||||
|
||||
if core.global_exists("awards") then
|
||||
if core.global_exists"awards" then
|
||||
i3.modules.awards = true
|
||||
|
||||
core.register_on_craft(function(_, player)
|
||||
|
|
36
src/gui.lua
36
src/gui.lua
|
@ -479,9 +479,39 @@ local function get_container(fs, data, player, yoffset, ctn_len, award_list, awa
|
|||
end
|
||||
|
||||
local armor_def = armor.def[name]
|
||||
fs(fmt("list[detached:%s_armor;armor;0,%f;3,2;]", esc_name, yextra + 0.7))
|
||||
label(3.65, yextra + 1.55, fmt("%s: %s", ES"Level", armor_def.level))
|
||||
label(3.65, yextra + 2.05, fmt("%s: %s", ES"Heal", armor_def.heal))
|
||||
fs(fmt("list[detached:%s_armor;armor;0,%f;5,1;]", esc_name, yextra + 0.7))
|
||||
|
||||
for i = 1, 5 do
|
||||
local _, armor_inv = armor:get_valid_player(player, "3d_armor")
|
||||
local stack = armor_inv:get_stack("armor", i)
|
||||
|
||||
if stack:is_empty() then
|
||||
local tips = {ES"Helmet", ES"Chest", ES"Leggings", ES"Boots", ES"Shield"}
|
||||
local x = (i - 1) + ((i - 1) * 0.15)
|
||||
local y = yextra + 0.7
|
||||
|
||||
image(x, y, 1, 1, fmt("i3_armor_%u.png", i))
|
||||
tooltip(x, y, 1, 1, tips[i])
|
||||
end
|
||||
end
|
||||
|
||||
local box_len, max_level, max_heal = 4, 85, 60
|
||||
local bar_lvl = (armor_def.level * box_len) / max_level
|
||||
local bar_heal = (armor_def.heal * box_len) / max_heal
|
||||
|
||||
fs"style_type[label;font_size=15]"
|
||||
|
||||
box(0.8, yextra + 1.95, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#9dc34c80,#9dc34c,#9dc34c,#9dc34c80]"
|
||||
box(0.8, yextra + 1.95, bar_lvl, 0.4, "")
|
||||
label(1.1, yextra + 2.15, ES"Armor level")
|
||||
|
||||
box(0.8, yextra + 2.55, box_len, 0.4, "#101010")
|
||||
fs"style_type[box;colors=#4466aa80,#4466aa,#4466aa,#4466aa80]"
|
||||
box(0.8, yextra + 2.55, bar_heal, 0.4, "")
|
||||
label(1.1, yextra + 2.75, ES"Armor healing")
|
||||
|
||||
fs"style_type[label;font_size=16]"
|
||||
|
||||
elseif data.subcat == 3 then
|
||||
if not i3.modules.skins then
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 186 B |
Binary file not shown.
After Width: | Height: | Size: 191 B |
Binary file not shown.
After Width: | Height: | Size: 175 B |
Binary file not shown.
After Width: | Height: | Size: 167 B |
Binary file not shown.
After Width: | Height: | Size: 141 B |
Ŝarĝante…
Reference in New Issue