Compare commits

..

5 Commits

2 changed files with 128 additions and 0 deletions

103
Mining_Things/digtunnel.lua Normal file
View File

@ -0,0 +1,103 @@
--[[digtunnel program from Sascha
Dig a tunnel until bedrock]]
os.loadAPI('hare')
isBedrock = false
level = 0
function comming_back(distance)
for i = 1, distance do
turtle.up()
end
end
function dig_around()
if is_bedrock() then
print('Found Bedrock. Comming back')
comming_back(level)
error('Done')
end
turtle.dig()
turtle.turnLeft()
if is_bedrock() == true then
print('Found Bedrock. Comming back')
comming_back(level)
error('Done')
end
turtle.dig()
turtle.turnRight()
turtle.turnRight()
if is_bedrock() then
print('Found Bedrock comming back')
comming_back(level)
error('done')
end
turtle.dig()
turtle.turnLeft()
end
function is_bedrock()
-- Check if we have Bedrock in Front
-- or underneath of us
local success, item = turtle.inspect()
if success == true and item['name'] == 'minecraft:bedrock' then
isBedrock = true
return true
else
return false
end
local success, item = turtle.inspectDown()
if success == true and item['name'] == 'minecraft;bedrock' then
isBedrock = true
else
return false
end
end
while isBedrock == false do
-- Dig one level down
if is_bedrock() then
print('Found Bedrock. Comming back')
comming_back(level)
error('Done')
end
turtle.digDown()
turtle.down()
level = level + 1
-- Dig a 3x3 Tunnel
dig_around()
turtle.forward()
dig_around()
turtle.forward()
turtle.turnLeft()
if is_bedrock() then
print('Found Bedrock. Comming back')
comming_back(level)
error('Done')
end
turtle.dig()
turtle.turnRight()
turtle.turnRight()
if is_bedrock() then
print('Found Bedrock. Comming back')
comming_back(level)
error('Done')
end
turtle.dig()
turtle.turnLeft()
-- place a ladder
local success, item = turtle.inspect()
if not success then
hare.selectItem('minecraft:cobblestone')
turtle.place()
end
turtle.back()
hare.selectItem('minecraft:ladder')
turtle.place()
hare.selectEmptySlot()
-- Go back to Start Position
turtle.back()
end

View File

@ -195,3 +195,28 @@ function findBlock(name)
end end
return false return false
end end
-- puke() puke everything that is in the turtles
-- inventory out in front of it (hopefully there is
-- a chest
function puke()
for i = 1, 16 do
turtle.select(i)
turtle.drop()
end
end
-- Check Fuel checks if the turtle has enough fuel.
-- if not, it asks for fuel in slot 1 and refuels.
function check_fuel()
local refueled = false
while not refueled do
if turtle.getFuelLevel() == 0 then
print("Fuel is empty. Please put fuel in slot 1 and press a key.")
read()
turtle.select(1)
turtle.refuel()
else
refueled = true
end
end