Compare commits
5 Commits
e68905578f
...
69e0a4555a
Author | SHA1 | Date | |
---|---|---|---|
69e0a4555a | |||
8e92de7a16 | |||
d6e6f6b850 | |||
68fa543ca7 | |||
df7f7bbb7e |
103
Mining_Things/digtunnel.lua
Normal file
103
Mining_Things/digtunnel.lua
Normal 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
|
||||
|
@ -195,3 +195,28 @@ function findBlock(name)
|
||||
end
|
||||
return false
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user