Small cleaning
This commit is contained in:
parent
1285a77060
commit
88b1e56c87
19
src/bags.lua
19
src/bags.lua
|
@ -77,35 +77,24 @@ local function init_bags(player)
|
||||||
local function save_content(inv)
|
local function save_content(inv)
|
||||||
local bagstack = bag:get_stack("main", 1)
|
local bagstack = bag:get_stack("main", 1)
|
||||||
local meta = bagstack:get_meta()
|
local meta = bagstack:get_meta()
|
||||||
|
meta:set_string("description", "")
|
||||||
|
|
||||||
if inv:is_empty"main" then
|
if inv:is_empty"main" then
|
||||||
meta:set_string("description", "")
|
|
||||||
meta:set_string("content", "")
|
meta:set_string("content", "")
|
||||||
else
|
else
|
||||||
local list = inv:get_list"main"
|
local list = inv:get_list"main"
|
||||||
local t = {}
|
local t, c = {}, 0
|
||||||
|
|
||||||
for i = 1, #list do
|
for i = 1, #list do
|
||||||
local stack = list[i]
|
local stack = list[i]
|
||||||
|
|
||||||
if not stack:is_empty() then
|
if not stack:is_empty() then
|
||||||
|
c = c + 1
|
||||||
t[i] = stack:to_string()
|
t[i] = stack:to_string()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function count_items()
|
local percent = fmt("%d", (c * 100) / (data.bag_size * 4))
|
||||||
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", "")
|
|
||||||
meta:set_string("description", ES("@1 (@2% full)", bagstack:get_description(), percent))
|
meta:set_string("description", ES("@1 (@2% full)", bagstack:get_description(), percent))
|
||||||
meta:set_string("content", slz(t))
|
meta:set_string("content", slz(t))
|
||||||
end
|
end
|
||||||
|
|
|
@ -155,7 +155,7 @@ local function add_subtitle(fs, name, y, ctn_len, font_size, sep, label)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_award_list(data, fs, ctn_len, yextra, award_list, awards_unlocked, award_list_nb)
|
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,
|
add_subtitle(fs, "awards", yextra, ctn_len, 18, false,
|
||||||
ES("Achievements: @1 of @2 (@3)", awards_unlocked, award_list_nb, percent))
|
ES("Achievements: @1 of @2 (@3)", awards_unlocked, award_list_nb, percent))
|
||||||
|
|
Ŝarĝante…
Reference in New Issue