Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shaftLength = 200
- minimumFuel = 500
- linesAlreadyDone = 2
- function itemIs(name)
- if (turtle.getItemDetail() and turtle.getItemDetail().name == ("minecraft:" .. name)) then
- if (name == "cobblestone") then
- if (turtle.getItemCount() > 1) then
- return true
- else
- return false
- end
- else
- return true
- end
- else
- return false
- end
- end
- function blockIs(name)
- test, table = turtle.inspect()
- if (test and table.name == ("minecraft:" .. name)) then
- return true
- else
- return false
- end
- end
- function blockDownIs(name)
- test, table = turtle.inspectDown()
- if (test and table.name == ("minecraft:" .. name)) then
- return true
- else
- return false
- end
- end
- function blockUpIs(name)
- test, table = turtle.inspect()
- if (test and table.name == ("minecraft:" .. name)) then
- return true
- else
- return false
- end
- end
- function dig()
- block = turtle.inspect()
- if (blockIs("chest") or blockIs("hopper")) then
- os.pullEvent("key")
- end
- turtle.dig()
- end
- function fill()
- turtle.select(2)
- if (itemIs("cobblestone")) then
- turtle.place()
- end
- end
- function fillDown()
- turtle.select(2)
- if (itemIs("cobblestone")) then
- turtle.placeDown()
- end
- end
- function fillUp()
- turtle.select(2)
- if (itemIs("cobblestone")) then
- turtle.placeUp()
- end
- end
- function refuel()
- if (turtle.getFuelLevel() < minimumFuel) then
- for i=1,16 do
- turtle.select(i)
- if (itemIs("coal")) then
- while(turtle.getFuelLevel() < minimumFuel and turtle.getItemCount() > 0) do
- turtle.refuel(1)
- end
- end
- end
- end
- end
- function forward()
- refuel()
- if (blockIs("lava") or blockIs("water")) then
- fill()
- turtle.dig()
- turtle.forward()
- if (blockUpIs("lava") or blockUpIs("water")) then
- fillUp()
- end
- turtle.turnLeft()
- if (blockIs("lava") or blockIs("water")) then
- fill()
- end
- turtle.turnRight()
- turtle.turnRight()
- if (blockIs("lava") or blockIs("water")) then
- fill()
- end
- turtle.turnLeft()
- elseif (not turtle.foward()) then
- if (blockIs("gravel") or blockIs("sand")) then
- dig()
- while (not turtle.forward()) do
- dig()
- end
- end
- end
- if (blockDownIs("lava") or blockDownIs("water")) then
- turtle.select(2)
- if (itemIs("cobblestone")) then
- placeDown()
- end
- end
- end
- function digShaft()
- for i=1, shaftLength do
- dig()
- forward()
- digUp()
- end
- end
- function digShaftWidth(n)
- for j = 1, n do
- for i = 1,4 do
- dig()
- forward()
- digUp()
- end
- end
- end
- function dropOff()
- refuel()
- for i=2,16 do
- turtle.select(i)
- if (i == 2) then
- turtle.drop(turtle.getItemCount() - 1)
- else
- if (itemIs("coal")) then
- turtle.drop(32)
- else
- turtle.drop()
- end
- end
- end
- end
- function stripMine(alreadyDone)
- for i = 1 + alreadyDone, 6 do
- if (i > 1) then
- turtle.turnRight()
- digShaftWidth(2*(i-1))
- turtle.turnLeft()
- end
- digShaft()
- turtle.turnRight()
- digShaftWidth(1)
- turtle.turnRight()
- digShaft()
- turtle.turnRight()
- digShaftWidth(2*i - 1)
- turtle.turnLeft()
- dropOff()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- stripMine(linesAlreadyDone)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement