From 7d35272289de9c3e8562017fa68e3af6e93d3774 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 28 Mar 2021 11:42:15 +0000 Subject: [PATCH] Add 'item-sorter.lua' --- item-sorter.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 item-sorter.lua diff --git a/item-sorter.lua b/item-sorter.lua new file mode 100644 index 0000000..69d9813 --- /dev/null +++ b/item-sorter.lua @@ -0,0 +1,32 @@ +-- Item Sorter. Filter list is specified in itemlist.txt. +-- Ejects listed items up and unlisted items down. +-- Filter list should look like this: +-- minecraft:carrot +-- minecraft:potato +-- foodexpansion:itemhorsemeat +-- ... + +while true do + for x=1,16 do + turtle.select(x) + local item = turtle.getItemDetail() + if item ~= nil then + local match = false + local file = fs.open("itemlist.txt", "r") + local cur = file.readLine() + while cur ~= nil do + if item.name == cur then + match = true + end + cur = file.readLine() + end + if match then + print("Match => " .. item.name) + turtle.dropUp() + else + print("No match => " .. item.name) + turtle.dropDown() + end + end + end +end \ No newline at end of file