Posted 17 July 2015 - 10:36 PM
I tried writing a simple turtle program to mine straight down and mine any ores it finds on the way. It was working perfectly until i tried getting the program to stop once it hit the surface again and now the program doesn't even run or give any errors
--Variables
blocks = 1
running = true
iron = "minecraft:iron_ore"
gold = "minecraft:gold_ore"
diamond = "minecraft:diamond_ore"
redstone = "minecraft:redstone_ore"
emerald = "minecraft:emerald_ore"
coal = "minecraft:coal_ore"
lapis = "minecraft:lapis_ore"
--Functions
function surface()
for i = 1, blocks do
turtle.up()
blocks = blocks - 1
if blocks == 0 then
running = false
end
end
function checkBedrock()
success, data = turtle.inspectDown()
if success == true and data.name == "minecraft:bedrock" then
surface()
end
end
function checkOre()
success, data = turtle.inspect()
if success == true and data.name == iron or data.name == gold or data.name == diamond or data.name == redstone or data.name == coal or data.name == lapis or data.name == emerald then
turtle.dig()
end
end
-- Main Program
while running == true do
print(blocks)
for i = 1,4 do
turtle.turnRight()
checkOre()
end
checkBedrock()
turtle.digDown()
turtle.down()
blocks = blocks + 1
end
Edited on 17 July 2015 - 09:44 PM