From 6dc12390dbbbd343de9a1bc513a5019d895cfa92 Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Sun, 27 Feb 2022 18:53:26 +0100 Subject: [PATCH] Tweak sorting --- src/common.lua | 9 ++++++--- src/gui.lua | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/common.lua b/src/common.lua index 7cc3922..b4aca41 100644 --- a/src/common.lua +++ b/src/common.lua @@ -514,14 +514,17 @@ local function compress_items(list, start_i) return new_inv end -local function drop_items(player, inv, list, start_i, rej) +local function drop_items(player, inv, list, start_i, rej, remove) for i = start_i, #list do local stack = list[i] local name = stack:get_name() for _, it in ipairs(rej) do if name == it then - spawn_item(player, stack) + if not remove then + spawn_item(player, stack) + end + inv:set_stack("main", i, ItemStack("")) end end @@ -537,7 +540,7 @@ local function sort_inventory(player, data) local start_i = data.ignore_hotbar and (i3.settings.hotbar_len + 1) or 1 if true_table(data.drop_items) then - list = drop_items(player, inv, list, start_i, data.drop_items) + list = drop_items(player, inv, list, start_i, data.drop_items, true) end if data.inv_compress then diff --git a/src/gui.lua b/src/gui.lua index f0f10a7..6c120d5 100644 --- a/src/gui.lua +++ b/src/gui.lua @@ -624,7 +624,7 @@ local function show_popup(fs, data) end fs("style[drop_items;font_size=15;font=mono;textcolor=#dbeeff]", - fmt("field[5.4,10.68;2.4,0.45;drop_items;Drop items:;%s]", + fmt("field[5.4,10.68;2.4,0.45;drop_items;Remove items:;%s]", ESC(concat(data.drop_items or {}, ","))), "field_close_on_enter[drop_items;false]") @@ -637,7 +637,7 @@ local function show_popup(fs, data) fmt("tooltip[cb_auto_sorting;%s;#707070;#fff]", ES"Enable this option to sort your inventory automatically"), fmt("tooltip[drop_items;%s;#707070;#fff]", - "Add a comma-separated list of items to drop on inventory sorting.\n" .. + "Add a comma-separated list of items to remove on inventory sorting.\n" .. "Format: " .. ("mod:item,mod:item, ..."):gsub("(%a+:%a+)", clr("#bddeff", "%1")))) end end