Skip to content

Commit

Permalink
Fix skin_id in skins dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbith committed Jul 6, 2021
1 parent f2cc874 commit 7e22562
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2053,16 +2053,21 @@ local function get_ctn_content(fs, data, player, yoffset, ctn_len, award_list, a
elseif data.subcat == 3 then
if __skinsdb then
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
end

sks = concat(sks, ","):gsub(";", "")

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
not_installed("skinsdb")
end
Expand Down Expand Up @@ -2563,10 +2568,10 @@ i3.new_tab {
local name = player:get_player_name()
local sb_inv = fields.scrbar_inv

if fields.skins and data.skin_id ~= tonum(fields.skins) then
data.skin_id = tonum(fields.skins)
if fields.skins then
local id = tonum(fields.skins)
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

for field in pairs(fields) do
Expand Down Expand Up @@ -3029,7 +3034,6 @@ end)
local META_SAVES = {
bag_size = true,
waypoints = true,
skin_id = true,
inv_items = true,
known_recipes = true,
}
Expand Down

0 comments on commit 7e22562

Please sign in to comment.