Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _channel = 7
- _dumpRock = true
- _stopOnFull = true
- gravDelay = 0
- fuelLimitLow = 1
- depth = 0
- width = 0
- height = 0
- modem = nil
- if(peripheral.getType("right") == "modem") then
- modem = peripheral.wrap("right")
- modem.open(_channel)
- elseif(peripheral.getType("left") == "modem") then
- modem = peripheral.wrap("left")
- modem.open(_channel)
- else
- print("No modem")
- end
- function tx(msg)
- if(modem ~= nil) then
- modem.transmit(_channel, _channel, os.getComputerLabel().."#"..os.getComputerID().." "..msg)
- end
- end
- function ping(currentDepth)
- tx(width.."x"..height.."x"..depth.." Depth:"..currentDepth.."\nFuel: "..turtle.getFuelLevel().."\nSlots empty: "..getEmptySlots())
- end
- function getEmptySlots()
- local num = 16
- for i = 1, 16, 1 do
- if(turtle.getItemCount(i) > 0) then
- num = num-1
- end
- end
- return num
- end
- function dumpRock()
- if(getEmptySlots() > 0 or _dumpRock == false) then
- return false
- end
- for i = 1, 16, 1 do
- if(turtle.getItemCount(i) > 0) then
- local data = turtle.getItemDetail(i)
- if(data.name == "minecraft:cobblestone" or data.name == "minecraft:stone" or data.name == "minecraft:dirt" or data.name == "minecraft:sand" or data.name == "minecraft:gravel" or data.name == "minecraft:netherrack") then
- turtle.select(i)
- turtle.drop()
- else
- --print("Not rock: "..data.name)
- end
- else
- --print("empty")
- end
- end
- if(getEmptySlots() == 0) then
- print("Slots full!")
- if(_stopOnFull == true) then
- print("Stopping on full!")
- while(getEmptySlots() == 0) do
- tx("FULL!")
- print("Empty me!")
- os.sleep(1)
- end
- else
- print("Not stopping!")
- end
- end
- end
- function fDig()
- dumpRock()
- while(turtle.dig()) do
- refuel()
- turtle.dig()
- sleep(gravDelay)
- end
- end
- function uDig()
- dumpRock()
- while(turtle.digUp()) do
- refuel()
- turtle.digUp()
- sleep(gravDelay)
- end
- end
- function dDig()
- while(turtle.digDown()) do
- refuel()
- turtle.digDown()
- sleep(gravDelay)
- end
- end
- function fMove()
- refuel()
- while(turtle.forward() == false) do
- fDig()
- end
- end
- function uMove()
- refuel()
- while(turtle.up() == false) do
- uDig()
- end
- end
- function dMove()
- refuel()
- while(turtle.down() == false) do
- dDig()
- end
- end
- function refuel()
- end
- function disp(w, h, d)
- term.clear()
- term.setCursorPos(1,1)
- print("Width [x]: ", w)
- print("Height [z]: ", h)
- print("Depth [y]: ", d)
- print("Fuel : ", turtle.getFuelLevel())
- print("Pinging on Ch. ", _channel)
- end
- print("Width:")
- width = tonumber(read())
- print("Height:")
- height = tonumber(read())
- print("Depth:")
- depth = tonumber(read())
- print(width, " x ", height, " x ", depth)
- for d = 1, depth do
- ping(d)
- fDig()
- fMove()
- turtle.turnLeft()
- for h = 1, height do
- for w = 1, width-1 do
- fDig()
- fMove()
- disp(w, h, d)
- end
- if(h < height) then
- turtle.turnLeft()
- turtle.turnLeft()
- uDig()
- turtle.up()
- else
- if(height % 2 == 0) then
- turtle.turnLeft()
- --print("Waiting for Gravity: ", gravDelay * height)
- --sleep(gravDelay * height)
- for i = 2, height do
- dMove()
- end
- else
- turtle.turnLeft()
- turtle.turnLeft()
- --print("Waiting for Gravity: ", gravDelay * height)
- --sleep(gravDelay * height)
- for i = 2, height do
- dMove()
- end
- for i = 2, width do
- fMove()
- end
- turtle.turnLeft()
- end
- end
- end
- end
- while(1) do
- print("Done.")
- tx("done")
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement