Changed the mining room script.
This commit is contained in:
parent
a1a3673536
commit
58f282e0bf
@ -1,5 +1,44 @@
|
||||
os.loadAPI("modules.lua")
|
||||
|
||||
function mine_line(length, height)
|
||||
local front = true
|
||||
-- Check if the user enters only 1 length or height.
|
||||
-- This is too short
|
||||
if length == 1 or height == 1 then
|
||||
print('Please choose a number higher than 1 for length and height.')
|
||||
return false
|
||||
end
|
||||
|
||||
for i = 1, height do
|
||||
for j = 1, length do
|
||||
modules.check_fuel()
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
end
|
||||
|
||||
-- Check if this is the last round to prevent digging up
|
||||
if i ~= height then
|
||||
modules.check_fuel()
|
||||
turtle.digUp()
|
||||
turtle.up()
|
||||
end
|
||||
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
front = not front
|
||||
end
|
||||
|
||||
-- Everything finisehd, go back to start
|
||||
if not front then
|
||||
for i = 1, length do
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
for i = 1, height - 1 do
|
||||
turtle.down()
|
||||
end
|
||||
end
|
||||
|
||||
print("How long should I dig?")
|
||||
local length = read()
|
||||
print("How wide should I dig?")
|
||||
@ -7,44 +46,4 @@ local width = read()
|
||||
print("How high should I dig?")
|
||||
local height = read()
|
||||
|
||||
local front = true
|
||||
for i = 1, width do
|
||||
for j = 1, height do
|
||||
for k = 1, length do
|
||||
modules.check_fuel()
|
||||
turtle.dig()
|
||||
turtle.forward()
|
||||
end
|
||||
if j ~= height do
|
||||
modules.check_fuel()
|
||||
turtle.digUp()
|
||||
turtle.up()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
front = not front
|
||||
end
|
||||
for tdown = 1, height do
|
||||
modules.check_fuel()
|
||||
turtle.down()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
turtle.turnLeft()
|
||||
if not front then
|
||||
for tfront = 1, length do
|
||||
modules.check_fuel()
|
||||
turtle.forward()
|
||||
end
|
||||
end
|
||||
turtle.turnRight()
|
||||
for twidth = 1, width -1 do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
modules.puke()
|
||||
turtle.turnLeft()
|
||||
for twidth = 1, width do
|
||||
turtle.forward()
|
||||
end
|
||||
turtle.turnLeft()
|
||||
end
|
||||
mine_line(length, height)
|
||||
|
Loading…
Reference in New Issue
Block a user