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

problems with inspecting ores

Started by superbosser, 14 April 2016 - 10:08 PM
superbosser #1
Posted 15 April 2016 - 12:08 AM
Hi all,
I was making a program to inspect the ores in the turtle, the idea is that I'll have a turtle strip mining and sending the ores per strip to a monitor so that I can get the ores myself if they are worthful.
Anyway, while making a program to inspect all the ores I ran into some trouble, whenever the turtle turns and I use turtle.inspect(), I get the value of the block that was originally in front and not after the turtle has turned. So if there is a iron ore in front of the turtle at the start and a cobblestone to the left the message will print the iron ore two times.
this is the code:
function checkOre()
local successf, f=turtle.inspect()
local successu, u=turtle.inspectUp()
local successd, d=turtle.inspectDown()
local tabl = {}
function checkD()
  turtle.inspectDown()
  if successd then
   table.insert(tabl,textutils.serialise(d))
  end
end
function checkU()
  turtle.inspectUp()
  if successu then
   table.insert(tabl,textutils.serialise(u))
  end
end
function checkF()
  turtle.inspect()
  if successf then
   table.insert(tabl,textutils.serialise(f))
  end
end
checkF()
checkD()
turtle.turnLeft()
checkF()
turtle.turnRight()
turtle.turnRight()
checkF()
turtle.turnLeft()
turtle.up()
checkF()
checkU()
turtle.turnLeft()
checkF()
turtle.turnRight()
turtle.turnRight()
checkF()
turtle.turnLeft()
turtle.down()
textutils.pagedTabulate(tabl)
end
checkOre()
for the record my output was:
BigReactors:YellowriteOre
ThermalFoundation:Ore
BigReactors:YellowriteOre
BigReactors:YellowriteOre
BigReactors:YellowriteOre
BigReactors:YellowriteOre
BigReactors:YellowriteOre

while I should have gotten something like:
BigReactors:YellowriteOre
ThermalFoundation:Ore
minecraft:cobblestone
minecraft:stone
minecraft:iron_ore
minecraft:stone
ThermalFoundation:Ore
minecraft:stone
Bomb Bloke #2
Posted 15 April 2016 - 02:50 AM
checkD() / checkU() / checkF() call turtle.inspectDown() / turtle.inspectUp() / turtle.inspect() respectively, but don't bother to assign the return values to anything.
superbosser #3
Posted 15 April 2016 - 07:16 AM
Thanks for the help now I see it indeed