diff --git a/init.lua b/init.lua index 00a3fc5..5375903 100644 --- a/init.lua +++ b/init.lua @@ -43,7 +43,8 @@ unified_inventory = { imgscale = 1.25, list_img_offset = 0.13, standard_background = "background9[0,0;1,1;ui_formbg_9_sliced.png;true;16]", - version = 2 + + version = 3 } local ui = unified_inventory diff --git a/internal.lua b/internal.lua index 7649bae..dd7415a 100644 --- a/internal.lua +++ b/internal.lua @@ -383,60 +383,3 @@ function ui.apply_filter(player, filter, search_dir) ui.set_inventory_formspec(player, ui.current_page[player_name]) end - -function ui.items_in_group(groups) - local items = {} - for name, item in pairs(minetest.registered_items) do - for _, group in pairs(groups:split(',')) do - if item.groups[group] then - table.insert(items, name) - end - end - end - return items -end - -function ui.sort_inventory(inv) - local inlist = inv:get_list("main") - local typecnt = {} - local typekeys = {} - for _, st in ipairs(inlist) do - if not st:is_empty() then - local n = st:get_name() - local w = st:get_wear() - local m = st:get_metadata() - local k = string.format("%s %05d %s", n, w, m) - if not typecnt[k] then - typecnt[k] = { - name = n, - wear = w, - metadata = m, - stack_max = st:get_stack_max(), - count = 0, - } - table.insert(typekeys, k) - end - typecnt[k].count = typecnt[k].count + st:get_count() - end - end - table.sort(typekeys) - local outlist = {} - for _, k in ipairs(typekeys) do - local tc = typecnt[k] - while tc.count > 0 do - local c = math.min(tc.count, tc.stack_max) - table.insert(outlist, ItemStack({ - name = tc.name, - wear = tc.wear, - metadata = tc.metadata, - count = c, - })) - tc.count = tc.count - c - end - end - if #outlist > #inlist then return end - while #outlist < #inlist do - table.insert(outlist, ItemStack(nil)) - end - inv:set_list("main", outlist) -end