Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- --- Created by deathsgun.
- --- DateTime: 2019-05-21 15:01
- ---
- local length, height, width = ...
- local delay = 0.25
- if length == nil or height == nil or width == nil then
- print("Usage: miner <length> <height> <width>")
- return false
- end
- X = 0;
- Y = 0;
- Z = 0;
- ORIENTATION = 0;
- function left()
- turtle.turnLeft()
- if ORIENTATION == 0 then
- ORIENTATION = 3
- else
- ORIENTATION = ORIENTATION - 1
- end
- end
- function right()
- turtle.turnRight()
- if ORIENTATION == 3 then
- ORIENTATION = 0
- else
- ORIENTATION = ORIENTATION + 1
- end
- end
- function up()
- while not turtle.up() do
- digUp()
- sleep(delay)
- end
- Y = Y + 1
- end
- function down()
- while not turtle.down() do
- digDown()
- sleep(delay)
- end
- Y = Y - 1
- end
- function forward()
- while not turtle.forward() do
- turtle.dig()
- turtle.attack()
- sleep(delay)
- end
- if ORIENTATION == 0 then
- X = X + 1
- elseif ORIENTATION == 1 then
- Z = Z + 1
- elseif ORIENTATION == 2 then
- X = X - 1
- elseif ORIENTATION == 3 then
- Z = Z - 1
- end
- end
- function orient(arg1)
- for _ =1, arg1 do
- right()
- end
- end
- function dig()
- while turtle.detect() do
- turtle.dig()
- sleep(delay)
- end
- end
- function digUp()
- while turtle.detectUp() do
- turtle.digUp()
- sleep(delay)
- end
- end
- function digDown()
- while turtle.detectDown() do
- turtle.digDown()
- sleep(delay)
- end
- end
- function go(lx,ly,lz)
- print("going to "..lx.."/"..ly.."/"..lz)
- if X < lx then
- orient(0)
- for _ =1,(lx-X) do
- forward()
- end
- end
- if X > lx then
- orient(2)
- for _ =1,X-lx do
- forward()
- end
- end
- if Y < ly then
- for _ =1,ly-Y do
- up()
- end
- end
- if Y > ly then
- for _ =1,Y-ly do
- down()
- end
- end
- if Z < lz then
- orient(1)
- for _ =1,lz-Z do
- forward()
- end
- end
- if Z > lz then
- orient(3)
- for _ =1,Z-lz do
- forward()
- end
- end
- end
- function deposit()
- for i=2,16 do
- turtle.select(i)
- while not turtle.drop() and turtle.getItemCount() ~= 0 do -- Waits until turtle can deposit item
- sleep(1)
- end
- turtle.drop()
- end
- turtle.select(1)
- return true
- end
- function check()
- if turtle.getItemCount(15) == 0 then
- return false
- else
- return true
- end
- end
- print("Creating a tunnel "..height.." x "..width.." "..length.." long!")
- lx = X
- ly = Y
- lz = Z
- for _ = 1, length do
- forward()
- lx = X
- ly = Y
- lz = Z
- for _ = 1, width do
- forward()
- for _ = 1, height do
- up()
- end
- go(X, ly, Z)
- if _ == 1 then
- right()
- end
- end
- go(lx, ly, lz)
- end
- go(0, 0, 0)
- orient(2)
- deposit()
- orient(0)
- print("Finished task!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement