Jump to content




problems with inspecting ores


  • You cannot reply to this topic
2 replies to this topic

#1 superbosser

  • Members
  • 3 posts

Posted 14 April 2016 - 11:08 PM

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

#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 15 April 2016 - 01:50 AM

checkD() / checkU() / checkF() call turtle.inspectDown() / turtle.inspectUp() / turtle.inspect() respectively, but don't bother to assign the return values to anything.

#3 superbosser

  • Members
  • 3 posts

Posted 15 April 2016 - 06:16 AM

Thanks for the help now I see it indeed





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users