This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
faolan89's profile picture

My program suddenly stopped working

Started by faolan89, 17 July 2015 - 08:36 PM
faolan89 #1
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
The_Cat #2
Posted 17 July 2015 - 11:04 PM
Is the area Chuck Loaded? Is there fuel in the turtle?
Edited on 17 July 2015 - 09:04 PM
faolan89 #3
Posted 17 July 2015 - 11:06 PM
Is the area Chuck Loaded? Is there fuel in the turtle?
I am standing right next to the turtle and staying there and i also have fuel turned off atm
MR_nesquick #4
Posted 17 July 2015 - 11:37 PM
You have missed placed an "end" remove the one at the bottom and put in under the "function surface"
faolan89 #5
Posted 17 July 2015 - 11:42 PM
You have missed placed an "end" remove the one at the bottom and put in under the "function surface"
It works now thanks