Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Tweak sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
kilbith committed Feb 27, 2022
1 parent 44610b8 commit 6dc1239
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/common.lua
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/gui.lua
Expand Up @@ -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]")

Expand All @@ -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
Expand Down

0 comments on commit 6dc1239

Please sign in to comment.