Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- inv=peripheral.wrap("left")
- state = "none"
- chatbox = 3478
- function _console(text)
- print(text)
- end
- function empty(side)
- if side == "top" then
- for i=1,16 do
- if turtle.getItemCount(i) then
- turtle.select(i)
- turtle.dropUp()
- end
- end
- elseif side == "bottom" then
- for i=1,16 do
- if turtle.getItemCount(i) then
- turtle.select(i)
- turtle.dropDown()
- end
- end
- else
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,16 do
- if turtle.getItemCount(i) then
- turtle.select(i)
- turtle.drop()
- end
- end
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- function pulse(side, delay)
- rs.setOutput(side, true)
- sleep(delay)
- rs.setOutput(side, false)
- sleep(delay)
- end
- function take()
- turtle.select(1)
- turtle.forward()
- turtle.turnLeft()
- while turtle.suck() == true do
- _console("Sucked a stack from deployer 2")
- end
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- while turtle.suck() == true do
- _console("Sucked a stack from deployer 1")
- end
- turtle.turnRight()
- turtle.back()
- turtle.back()
- for i=3,16 do
- if turtle.getItemCount(i) > 0 then
- state = "none"
- end
- end
- if state == "normal" then
- empty("bottom")
- elseif state == "indus" then
- empty("top")
- else
- empty("back")
- end
- state = "none"
- end
- function drop()
- if turtle.getItemCount(1) > 0 and turtle.getItemCount(2) > 0 then
- turtle.forward()
- turtle.turnLeft()
- turtle.select(1)
- turtle.drop()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- turtle.select(2)
- turtle.drop()
- turtle.turnRight()
- turtle.back()
- turtle.back()
- end
- end
- function giveIndus()
- turtle.select(1)
- for i=1,2 do
- if turtle.suckUp() == false then
- return false
- end
- end
- if turtle.getItemCount(2) < 64 then
- turtle.suckUp()
- if turtle.getItemCount(3) > 0 then
- turtle.select(3)
- turtle.dropUp()
- end
- end
- drop()
- state = "indus"
- end
- function giveNormal()
- turtle.select(1)
- for i=1,2 do
- if turtle.suckDown() == false then
- return false
- end
- end
- if turtle.getItemCount(2) < 64 then
- turtle.suckDown()
- if turtle.getItemCount(3) > 0 then
- turtle.select(3)
- turtle.dropDown()
- end
- end
- drop()
- state = "normal"
- end
- function giveSand()
- turtle.select(1)
- turtle.turnRight()
- for i=1,2 do
- if turtle.suck() == false then
- return false
- end
- end
- if turtle.getItemCount(2) < 64 then
- turtle.suck()
- if turtle.getItemCount(3) > 0 then
- turtle.select(3)
- turtle.drop()
- end
- end
- turtle.turnLeft()
- drop()
- state = "sand"
- end
- while true do
- sender, message = rednet.receive()
- if sender == chatbox then
- if message == "take" then
- take()
- elseif message == "giveIndus" then
- take()
- giveIndus()
- rednet.send(chatbox, "ok")
- elseif message == "giveNormal" then
- take()
- giveNormal()
- rednet.send(chatbox, "ok")
- elseif message == "giveSand" then
- take()
- giveSand()
- rednet.send(chatbox, "ok")
- else
- _console("Erreur: Message non compris. "..message)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement