Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ckFuel()
- if turtle.getFuelLevel() == 0 then
- turtle.refuel(1)
- end
- end
- function digFW()
- while not turtle.forward() do
- ckFuel()
- turtle.dig()
- end
- end
- function digUP()
- while not turtle.up() do
- ckFuel()
- turtle.digUp()
- end
- ckFuel()
- turtle.down()
- end
- function tunnelLength()
- local l = 10
- print("Set Tunnel's Length, default is 10")
- print("Tunnel's length?")
- l = read()
- if l == "" then
- l = 10
- end
- return l
- end
- function tunnelWidth()
- local w = 1
- print("Set Tunnel's Width, default is 1")
- print("Tunnel's width?")
- w = read()
- if w == "" then
- w = 1
- end
- return w
- end
- function gridRows()
- local r = 10
- print("Set Grid's raws, default is 10")
- print("Grid's Raws?")
- r = read()
- if r == "" then
- r = 10
- end
- return r
- end
- function gridColumns()
- local c = 10
- print("Set Grid's columns, default is 10")
- print("Grid's columns?")
- c = read()
- if c == "" then
- c = 10
- end
- return c
- end
- function placeTorch()
- turtle.select(2)
- if turtle.compareTo(3) then
- turtle.select(2)
- turtle.placeDown()
- turtle.select(1)
- end
- end
- function digSides(j,width,torches)
- if j%2 == 0 then
- turtle.turnRight()
- ckFuel()
- digWalls(width/2,torches)
- turtle.turnLeft()
- elseif j%2 == 1 then
- turtle.turnLeft()
- ckFuel()
- digWalls(width/2,torches)
- turtle.turnRight()
- end
- end
- function digWalls(length,torches)
- for i=1, length do
- ckFuel()
- digFW()
- ckFuel()
- turtle.digDown()
- turtle.suckDown()
- ckFuel()
- digUP()
- if torches == "y" then
- if i%10 == 0 then
- placeTorch()
- end
- end
- end
- -- check fuel than back to the starting point
- for i = 1 , length do
- ckFuel()
- turtle.back()
- end
- if turtle.getFuelLevel() == 0 then
- print("Turtle as no more fuel!!!")
- end
- function digTunnel(length,width,torches)
- for i=1, length do
- ckFuel()
- digFW()
- ckFuel()
- turtle.digDown()
- turtle.suckDown()
- ckFuel()
- digUP()
- if width ~= 1 then
- for j=2, width do
- if j <= 3 then
- digSides(j,width,torches)
- end
- end
- end
- if torches == "y" then
- if i%10 == 0 then
- placeTorch()
- end
- end
- end
- -- check fuel than back to the starting point
- for i = 1 , length do
- ckFuel()
- turtle.back()
- end
- if turtle.getFuelLevel() == 0 then
- print("Turtle as no more fuel!!!")
- end
- end
- function tripleFW()
- ckFuel()
- turtle.forward()
- ckFuel()
- turtle.forward()
- ckFuel()
- turtle.forward()
- ckFuel()
- end
- function digGridTunnel(rows,columns,step,torches)
- for r=1,rows do
- ckFuel()
- digFW()
- ckFuel()
- turtle.digDown()
- turtle.suckDown()
- ckFuel()
- digUP()
- if torches == "y" then
- if r%10 == 0 then
- placeTorch()
- end
- end
- if tonumber(columns) == 1 or tonumber(columns)%2 == 1 then
- if r ~= 0 and r ~= 1 and r%step == 0 then
- ckFuel()
- turtle.turnRight()
- digTunnel(2,torches)
- turtle.turnLeft()
- turtle.turnLeft()
- ckFuel()
- digTunnel(2,torches)
- turtle.turnRight()
- end
- end
- end
- if tonumber(columns) >1 and tonumber(columns)%2 ==0 then
- turtle.turnRight()
- ckFuel()
- digTunnel(2,torches)
- turtle.turnLeft()
- ckFuel()
- elseif tonumber(columns)%2 == 0 then
- turtle.turnLeft()
- ckFuel()
- digTunnel(2,torches)
- turtle.turnRight()
- ckFuel()
- end
- end
- function digGrid(rows,columns,step,torches)
- if step == 0 then
- step = 3
- end
- digGridTunnel(rows,1,step,torches)
- ckFuel()
- turtle.turnRight()
- digTunnel(3,torches)
- ckFuel()
- tripleFW()
- turtle.turnRight()
- if tonumber(columns) >2 then
- digGridTunnel(rows,2,step,torches)
- ckFuel()
- turtle.turnLeft()
- digTunnel(3,torches)
- ckFuel()
- tripleFW()
- turtle.turnLeft()
- end
- if tonumber(columns) >= 3 then
- for c = 3, columns do
- digGridTunnel(rows,c,step,torches)
- if c%2 == 1 then
- ckFuel()
- turtle.turnRight()
- digTunnel(3,torches)
- tripleFW()
- turtle.turnRight()
- elseif c%2 == 0 then
- ckFuel()
- turtle.turnLeft()
- digTunnel(3,torches)
- tripleFW()
- turtle.turnLeft()
- end
- end
- end
- end
- print("Piddu's Automine Turtle")
- local l
- local w
- local p = ""
- local t = ""
- local rows = 0
- local columns = 0
- local step = 3
- print("Chose a Mine Pattern:")
- print("- single tunnel pattern, press 1")
- print("- grid pattern, press 2")
- p = read()
- if p == "1" then
- l = tunnelLength()
- w = tunnelWidth()
- print("Torch placement? y n:")
- t = read()
- digTunnel(l,w,t)
- print("Job Done")
- elseif p == "2" then
- rows = gridRows()
- columns = gridColumns()
- print("Torch placement? y n:")
- t = read()
- digGrid(rows,columns,step,t)
- print("Job Done")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement