Small cleaning

This commit is contained in:
Jean-Patrick Guerrero 2021-11-23 01:47:59 +01:00
parent 1285a77060
commit 88b1e56c87
2 changed files with 5 additions and 16 deletions

View File

@ -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

View File

@ -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))