diff --git a/src/bags.lua b/src/bags.lua index 3233231..4f1fa25 100644 --- a/src/bags.lua +++ b/src/bags.lua @@ -77,35 +77,24 @@ local function init_bags(player) local function save_content(inv) local bagstack = bag:get_stack("main", 1) local meta = bagstack:get_meta() + meta:set_string("description", "") if inv:is_empty"main" then - meta:set_string("description", "") meta:set_string("content", "") else local list = inv:get_list"main" - local t = {} + local t, c = {}, 0 for i = 1, #list do local stack = list[i] if not stack:is_empty() then + c = c + 1 t[i] = stack:to_string() end end - local function count_items() - local c = 0 - - for _ in pairs(t) do - c = c + 1 - end - - return c - end - - local percent = fmt("%.1f", (count_items() * 100) / (data.bag_size * 4)) - - meta:set_string("description", "") + local percent = fmt("%d", (c * 100) / (data.bag_size * 4)) meta:set_string("description", ES("@1 (@2% full)", bagstack:get_description(), percent)) meta:set_string("content", slz(t)) end diff --git a/src/gui.lua b/src/gui.lua index 788b139..31aae9d 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -155,7 +155,7 @@ local function add_subtitle(fs, name, y, ctn_len, font_size, sep, label) end local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlocked, award_list_nb) - local percent = fmt("%.1f%%", (awards_unlocked * 100) / award_list_nb):gsub(".0", "") + local percent = fmt("%.1f%%", (awards_unlocked * 100) / award_list_nb):gsub("%.0", "") add_subtitle(fs, "awards", yextra, ctn_len, 18, false, ES("Achievements: @1 of @2 (@3)", awards_unlocked, award_list_nb, percent))