Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function loadList()
- local r = {}
- local f = fs.open("classlist","r")
- if f == nil then return r end
- local line = f.readLine()
- while line do
- r[line] = 1
- write(line.."\n")
- line = f.readLine()
- end
- f.close()
- return r
- end
- function addList( add )
- local f = fs.open("classlist","a")
- f.writeLine(add)
- write(add.."\n")
- f.close()
- end
- function isList(list,target)
- if list[target] == nil then
- return false
- else
- return true
- end
- end
- function checkSelf( list,self )
- for k, v in pairs(self.getAllStacks()) do
- if not isList(list,v.all().raw_name) then
- addList(v.all().raw_name)
- list[v.all().raw_name] = 1
- end
- turtle.select(k)
- turtle.drop()
- end
- end
- local list = loadList()
- local chest = peripheral.wrap("front")
- local self = nil
- for k, v in pairs(peripheral.getNames()) do
- if peripheral.getType(v) == "tile_computercraft_turtle_name" then
- self = peripheral.wrap(v)
- end
- end
- if not ( chest and chest.getInventorySize() > 20 ) then
- write("need chest front.\n")
- shell.exit()
- end
- if not self then
- write("need narcissictic turtle.\n")
- shell.exit()
- end
- while true do
- checkSelf(list,self)
- local nonwait = false
- for k, v in pairs(chest.getAllStacks()) do
- if isList(list,v.all().raw_name) then
- nonwait = chest.pushItem("down",k)
- else
- nonwait = chest.pushItem("up",k)
- end
- if not nonwait then sleep(1) end
- end
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement