Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("left")
- modem.open(403)
- modem.transmit(403, 403, "listening-port")
- print("listening for port")
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- port = message
- modem.open(port)
- print("opened port")
- modem.close(403)
- modem.transmit(port, port, "listening-position")
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- distanceToGo = message
- print(distanceToGo)
- fullSlotCounter = 0
- function await(x)
- awaitVar = true
- while awaitVar == true do
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == x then
- awaitVar = false
- end
- end
- end
- function checkFuel()
- if turtle.getFuelLevel() < 401 then
- turtle.select(14)
- turtle.refuel(8)
- turtle.select(1)
- end
- end
- function enderChests()
- -- Unload slot 1 - 13
- turtle.dig()
- turtle.select(15)
- turtle.place()
- for i = 1, 13 , 1 do
- turtle.select(i)
- turtle.drop()
- end
- turtle.select(15)
- turtle.dig()
- -- Load Slot 14 with coal
- turtle.select(16)
- turtle.place()
- if turtle.getItemCount(14) < 64 then
- turtle.select(14)
- turtle.suck(64 - turtle.getItemCount(14))
- end
- turtle.select(16)
- turtle.dig()
- end
- function checkInv()
- if turtle.getItemCount(14) < 2 then
- enderChests()
- else
- for i = 1, 13, 1 do
- if turtle.getItemCount(i) > 0 then
- fullSlotCounter = fullSlotCounter + 1
- end
- end
- if fullSlotCounter > 10 then
- enderChests()
- end
- end
- fullSlotCounter = 0
- checkFuel()
- end
- function getInPostion()
- for i = 1, distanceToGo, 1 do
- turtle.dig()
- turtle.forward()
- print(i)
- end
- turtle.turnLeft()
- print("aqquired position")
- end
- function acceptOrder()
- print("ready for parameters")
- await("values-incoming")
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- width = message
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- height = message
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- depth = message
- end
- function executeOrder()
- checkInv()
- for z = 1, depth, 1 do
- turtle.turnRight()
- for y = 1, height, 1 do
- checkInv()
- for x = 1, width - 1, 1 do
- turtle.dig()
- turtle.forward()
- checkInv()
- end
- if y < height then
- turtle.digUp()
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.up()
- end
- end
- for i = 1, height - 1, 1 do
- turtle.digDown()
- turtle.down()
- end
- if (depth % 2) == 1 then
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, width - 1, 1 do
- turtle.forward()
- end
- end
- if z == depth then
- turtle.turnRight()
- turtle.turnRight()
- turtle.turnRight()
- turtle.dig()
- enderChests()
- else
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- end
- end
- end
- function goHome()
- for i = 1, depth - 1, 1 do
- checkInv()
- turtle.dig()
- turtle.forward()
- end
- turtle.turnLeft()
- modem.transmit(port, port, "arrived-home")
- end
- -- Actual program
- turtle.turnLeft()
- checkInv()
- turtle.turnRight()
- getInPostion()
- acceptOrder()
- executeOrder()
- goHome()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement