This commit is contained in:
Jean-Patrick Guerrero 2021-01-16 03:41:45 +01:00
parent 04ea2e6877
commit 0859e9bf16

View File

@ -2071,11 +2071,7 @@ local function common_fields(player, data, fields)
end
end
i3.new_tab {
name = "inventory",
description = S"Inventory",
formspec = function(player, data, fs)
local function get_inventory_fs(player, data, fs)
local inv_x = 0.234
for i = 0, 7 do
@ -2134,8 +2130,7 @@ i3.new_tab {
end
end
max_val = max_val +
(award_list_nb * (12.9 + ((__3darmor or __skinsdb) and 0.25 or 0)))
max_val = max_val + (award_list_nb * (12.9 + ((__3darmor or __skinsdb) and 0.25 or 0)))
end
fs(fmt([[
@ -2167,46 +2162,9 @@ i3.new_tab {
fs(fmt("image_button", i + 3.447 - (i * 0.4), 11.13, 0.35, 0.35, "", btn_name, ""))
fs(fmt("tooltip[%s;%s]", btn_name, tooltip))
end
end,
fields = function(player, data, fields)
local name = player:get_player_name()
local sb_inv = fields.scrbar_inv
common_fields(player, data, fields)
if fields.skins and data.skin_id ~= tonum(fields.skins) then
data.skin_id = tonum(fields.skins)
local _skins = skins.get_skinlist_for_player(name)
skins.set_player_skin(player, _skins[data.skin_id])
end
if fields.trash then
local inv = player:get_inventory()
if not inv:is_empty("main") then
inv:set_list("main", {})
end
elseif fields.compress then
compress_items(player)
elseif fields.sort_az or fields.sort_za then
sort_itemlist(player, fields.sort_az)
elseif sb_inv and sub(sb_inv, 1, 3) == "CHG" then
data.scrbar_inv = tonum(match(sb_inv, "%d+"))
return
end
return set_fs(player)
end,
}
i3.new_tab {
name = "items",
description = S"Items",
formspec = function(player, data, fs)
local function get_items_fs(player, data, fs)
local filtered = data.filter ~= ""
fs("box[0.2,0.2;4.55,0.6;#bababa25]", "set_focus[filter]")
@ -2255,7 +2213,50 @@ i3.new_tab {
fs(fmt("item_image_button", X, Y, 1, 1, item, fmt("%s_inv", item), ""))
end
end
i3.new_tab {
name = "inventory",
description = S"Inventory",
formspec = get_inventory_fs,
fields = function(player, data, fields)
local name = player:get_player_name()
local sb_inv = fields.scrbar_inv
common_fields(player, data, fields)
if fields.skins and data.skin_id ~= tonum(fields.skins) then
data.skin_id = tonum(fields.skins)
local _skins = skins.get_skinlist_for_player(name)
skins.set_player_skin(player, _skins[data.skin_id])
end
if fields.trash then
local inv = player:get_inventory()
if not inv:is_empty("main") then
inv:set_list("main", {})
end
elseif fields.compress then
compress_items(player)
elseif fields.sort_az or fields.sort_za then
sort_itemlist(player, fields.sort_az)
elseif sb_inv and sub(sb_inv, 1, 3) == "CHG" then
data.scrbar_inv = tonum(match(sb_inv, "%d+"))
return
end
return set_fs(player)
end,
}
i3.new_tab {
name = "items",
description = S"Items",
formspec = get_items_fs,
fields = function(player, data, fields)
common_fields(player, data, fields)