ComputerCraft/Mining_Things/mining_room.lua

50 lines
1023 B
Lua

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?")
local width = read()
print("How high should I dig?")
local height = read()
mine_line(length, height)