Fix skin_id in skins dropdown

This commit is contained in:
Jean-Patrick Guerrero 2021-07-06 10:58:19 +02:00
parent f2cc874ec0
commit 7e2256253d

View File

@ -2053,16 +2053,21 @@ local function get_ctn_content(fs, data, player, yoffset, ctn_len, award_list, a
elseif data.subcat == 3 then elseif data.subcat == 3 then
if __skinsdb then if __skinsdb then
local _skins = skins.get_skinlist_for_player(name) local _skins = skins.get_skinlist_for_player(name)
local sks = {} local skin_name = skins.get_player_skin(player).name
local sks, id = {}, 1
for i, skin in ipairs(_skins) do
if skin.name == skin_name then
id = i
end
for _, skin in ipairs(_skins) do
sks[#sks + 1] = skin.name sks[#sks + 1] = skin.name
end end
sks = concat(sks, ","):gsub(";", "") sks = concat(sks, ","):gsub(";", "")
fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin")) fs("label", 0, yextra + 0.85, fmt("%s:", ES"Select a skin"))
fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, data.skin_id or 1)) fs(fmt("dropdown[0,%f;4,0.6;skins;%s;%u;true]", yextra + 1.1, sks, id))
else else
not_installed("skinsdb") not_installed("skinsdb")
end end
@ -2563,10 +2568,10 @@ i3.new_tab {
local name = player:get_player_name() local name = player:get_player_name()
local sb_inv = fields.scrbar_inv local sb_inv = fields.scrbar_inv
if fields.skins and data.skin_id ~= tonum(fields.skins) then if fields.skins then
data.skin_id = tonum(fields.skins) local id = tonum(fields.skins)
local _skins = skins.get_skinlist_for_player(name) local _skins = skins.get_skinlist_for_player(name)
skins.set_player_skin(player, _skins[data.skin_id]) skins.set_player_skin(player, _skins[id])
end end
for field in pairs(fields) do for field in pairs(fields) do
@ -3029,7 +3034,6 @@ end)
local META_SAVES = { local META_SAVES = {
bag_size = true, bag_size = true,
waypoints = true, waypoints = true,
skin_id = true,
inv_items = true, inv_items = true,
known_recipes = true, known_recipes = true,
} }