Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = {...}
- chunkName = args[1]
- chunksNum = 0
- turtle.select(1)
- queen = false
- movingForward = true
- turtID = 1
- timeInMinutes = 1200
- turnAroundTime = math.ceil(((timeInMinutes*60)/20)/2)
- function fuelUp()
- if turtle.getFuelLevel() < 50 then
- print(turtle.getFuelLevel())
- turtle.select(16)
- turtle.refuel()
- turtle.select(15)
- turtle.refuel()
- end
- turtle.select(1)
- end
- function checkInventory(inventoryLimit)
- local isFull = true
- for apple = 1, inventoryLimit do
- if turtle.getItemCount(apple) == 0 then
- isFull = false
- end
- end
- return isFull
- end
- function deposit()
- if checkInventory(13) == true then
- local bubble = 1
- if queen == true then
- bubble = 2
- end
- for apple = bubble, 13 do
- local data = turtle.getItemDetail(apple)
- if data ~= nil then
- if data.name ~= "create:crushed_copper_ore" and data.name ~= "create:crushed_zinc_ore" then
- turtle.select(apple)
- turtle.drop()
- end
- end
- end
- if checkInventory(8) == true then
- turtle.select(14)
- while turtle.placeDown() == false do
- turtle.digDown()
- end
- for apple = bubble, 13 do
- if turtle.getItemCount(apple) ~= 0 then
- turtle.select(apple)
- turtle.dropDown()
- end
- end
- turtle.select(14)
- turtle.digDown()
- end
- end
- turtle.select(1)
- end
- function move()
- while turtle.forward() == false do
- turtle.dig()
- deposit()
- end
- local has_block, data = turtle.inspectDown()
- if data.name == "create:copper_ore" or data.name == "create:zinc_ore" then
- turtle.digDown()
- deposit()
- end
- local has_block, data = turtle.inspectUp()
- if data.name == "create:copper_ore" or data.name == "create:zinc_ore" then
- turtle.digUp()
- deposit()
- end
- end
- function turnTurtleAround()
- if tonumber(turtID) % 2 ~= 0 then
- os.sleep(40)
- end
- turtle.turnRight()
- for x = 1, 14 do
- move()
- end
- turtle.turnRight()
- movingForward = false
- end
- function mainCode()
- for x = 1, turnAroundTime do
- while tonumber(message) ~= chunksNum do
- print("message:"..message.."~=".."chunksNum:"..tostring(chunksNum))
- for x = 1, 4 do
- move()
- fuelUp()
- end
- for x = 1, 8 do
- while turtle.forward() == false do
- turtle.dig()
- deposit()
- end
- end
- for x = 1, 4 do
- move()
- fuelUp()
- end
- if movingForward == true then
- chunksNum = chunksNum + 1
- else
- chunksNum = chunksNum -1
- end
- end
- -- Rednet stuff
- print("starting rednet")
- if tonumber(turtID) == 8 then
- while true do
- rednet.broadcast(done, chunkName..tostring(turtID-1))
- print("test1")
- id, message = rednet.receive(chunkName.."chunk", 3)
- print("test2")
- if message ~= nil then
- print("test3")
- break
- end
- end
- end
- if tonumber(turtID) < 8 and tonumber(turtID) ~= 1 then
- while true do
- print("test1")
- id, message = rednet.receive(chunkName..tostring(turtID))
- print("test2")
- rednet.broadcast(done, chunkName..tostring(turtID-1))
- print("test3")
- id, message = rednet.receive(chunkName.."chunk", 1.5)
- print("test4")
- if message ~= nil then
- print("test5")
- break
- end
- end
- end
- if tonumber(turtID) == 1 then
- turtle.equipRight(1)
- rednet.open("right")
- rednet.broadcast("Im stil going:"..chunksNum, "Margey"..chunkName)
- while true do
- print("test1")
- id, message = rednet.receive(chunkName..tostring(turtID))
- print("test2")
- if movingForward == true then
- rednet.broadcast(tostring(chunksNum + 1), chunkName.."chunk")
- message = chunksNum + 1
- else
- rednet.broadcast(tostring(chunksNum - 1), chunkName.."chunk")
- message = chunksNum - 1
- end
- print("test3")
- break
- end
- turtle.equipRight(1)
- end
- print("stoping rednet")
- end
- end
- fuelUp()
- if args[2] ~= nil then
- turtle.equipRight(1)
- rednet.open("right")
- queen = true
- numberOfTurts = 1
- while numberOfTurts < 8 do
- numberOfTurts = numberOfTurts + 1
- id, message = rednet.receive(chunkName)
- os.sleep(0.2)
- rednet.broadcast(tostring(numberOfTurts), chunkName)
- end
- os.sleep(1.5)
- rednet.broadcast(tostring(chunksNum + 1), chunkName.."chunk")
- turtle.equipRight(1)
- else
- rednet.open("left")
- rednet.broadcast("", chunkName)
- id, turtID = rednet.receive(chunkName)
- end
- print("Turtle Number "..turtID.." Is Ready!")
- if queen == false then
- id, message = rednet.receive(chunkName.."chunk")
- else
- message = 1
- end
- mainCode()
- turnTurtleAround()
- message = tostring(tonumber(message) - 2)
- mainCode()
- if queen == true then
- turtle.equipLeft(1)
- end
- print("Im done mining!!!!!!")
Add Comment
Please, Sign In to add comment