Add 'item-sorter.lua'

This commit is contained in:
Jan 2021-03-28 11:42:15 +00:00
parent 5bdd0c7b23
commit 7d35272289

32
item-sorter.lua Normal file
View file

@ -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