Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------
- --storage check system ver1.0
- ----------------setting--------------------
- os.loadAPI("logging")
- receiverComputerID = 2
- suckDirecton = turtle.suckUp
- shelfX = 6
- shelfY = 2
- ----------------function-------------------
- function refAll(suckDirecton)
- while turtle.getFuelLevel() < 200 do
- suckDirecton()
- turtle.refuel()
- LP.sendMessage(receiverComputerID,-1)
- os.sleep(2)
- end
- end
- LC = 0
- filledLC = 0
- function rsDetect()
- for i=1,4 do
- logging.turnLeft()
- boolean,data = turtle.inspect()
- if boolean then
- if string.find(data.name,"Tra") ==12 then
- if redstone.getInput("front") then
- filledLC = filledLC + 1
- end
- LC = LC +1
- end
- end
- end
- end
- function sweep(shelfX,shelfY)
- for y=1,shelfY do
- for x=1,shelfX do
- logging.forward()
- rsDetect()
- end
- logging.down()
- rsDetect()
- logging.turnLeft()
- logging.turnLeft()
- end
- if shelfY/2 ~= 0 then
- for y=1,shelfY do
- logging.up()
- end
- else
- logging.up()
- for x=1,shelfX do
- logging.forward()
- end
- end
- end
- ------------------main----------------------
- if fs.exists(logging.LOG_FILE) then
- term.write("Return to home position..")
- logging.makeRevFile()
- logging.backupFile(logging.LOG_FILE)
- logging.backupFile(logging.REV_FILE)
- shell.run(logging.REV_FILE.."-bak")
- print("ok")
- end
- for k, v in pairs(peripheral.getNames()) do
- if string.find(peripheral.getType(v),"Logi") == 1 then
- LP = peripheral.wrap(v)
- end
- end
- while true do
- LC,filledLC = 0,0
- refAll(suckDirecton)
- sweep(shelfX,shelfY)
- inf = filledLC*1000+LC/1000
- LP.sendMessage(receiverComputerID,inf)
- fs.delete("mylog")
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement