Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- local prevLiquid = -1
- function place()
- turtle.select(1)
- turtle.place()
- turtle.back()
- turtle.select(2)
- turtle.place()
- turtle.up()
- turtle.select(3)
- turtle.place()
- prevLiquid = -1
- end
- function brk()
- turtle.select(3)
- turtle.dig()
- turtle.down()
- turtle.select(2)
- turtle.dig()
- turtle.select(1)
- turtle.forward()
- turtle.dig()
- end
- function move()
- turtle.turnRight()
- for i = 1, 10 do
- turtle.forward()
- sleep(2)
- end
- end
- function hasLessLiquid()
- local tank = peripheral.wrap("front")
- local amount = tank.getTankInfo("front")[1]["amount"]
- if amount < prevLiquid then
- return true
- end
- prevLiquid = amount
- return false
- end
- function waitForTankOrMsg()
- while true do
- local id,msg = rednet.receive(5)
- if id ~= nil and msg ~= nil then
- if id == 1 and msg == "break" then
- brk()
- end
- else
- if hasLessLiquid() then
- sendStop()
- break
- end
- end
- end
- end
- function sendStop()
- rednet.send(1,"break")
- end
- while true do
- id,msg = rednet.receive()
- if id == 1 then
- if msg == "place" then
- place()
- waitForTankOrMsg()
- elseif msg == "move" then
- move()
- elseif msg == "break" then
- brk()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement