Add 'item-sorter.lua'
This commit is contained in:
parent
5bdd0c7b23
commit
7d35272289
32
item-sorter.lua
Normal file
32
item-sorter.lua
Normal 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
|
Loading…
Reference in a new issue