Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem = peripheral.wrap("back")
- modem.open(5555)
- accepted = false
- fullSlotCounter = 0
- waitInput = true
- while waitInput == true do
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- if message == "start-mining" then
- waitInput = false
- end
- end
- function getValues()
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- width = tonumber(message)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- height = tonumber(message)
- event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- depth = tonumber(message)
- end
- function approximitTime()
- approximitTime = ((width * height * depth) * 0.75) + 5
- end
- function sendConfirm()
- modem.transmit(5555, 5555, "Mining started, approximitly "..approximitTime.." seconds left...")
- end
- function refuel()
- if turtle.getFuelLevel() < 801 then
- turtle.select(14)
- turtle.refuel(16)
- turtle.select(1)
- end
- end
- function checkInv()
- refuel()
- 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 > 12 then
- enderChests()
- end
- end
- fullSlotCounter = 0
- 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 startMining()
- enderChests()
- refuel()
- turtle.forward()
- for z = 1, depth, 1 do
- turtle.turnRight()
- for y = 1, height, 1 do
- 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.down()
- end
- if (depth % 2) == 1 then
- turtle.turnRight()
- turtle.turnRight()
- for i = 1, width - 1, 1 do
- turtle.forward()
- end
- end
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- end
- turtle.dig()
- enderChests()
- end
- -- Actual program
- if message == "start-mining" then
- getValues()
- approximitTime()
- sendConfirm()
- startMining()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement