computercraft-scripts/item-sorter.lua

32 lines
785 B
Lua
Raw Normal View History

2021-03-28 11:42:15 +00:00
-- 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