r/ComputerCraft • u/hengwozzle • Apr 05 '21
Trouble with turtle.detect() command
Hello all. I'm having some trouble with the turtle.detect() command in the modpack Project Ozone 2 (Minecraft 1.7). Here is the code:
if turtle.detect() then
print("yes")
else
print("no")
end
Running the code does nothing at all, though it should output to the console one of either 'yes' or 'no', correct? I've tried making a completely new advanced turtle with just that program in it, still doesn't work. What am I doing wrong? All the other commands in my larger script are working, it's just turtle.detect() and turtle.inspect() that are behaving oddly.
3
Upvotes
3
u/Immow Apr 06 '21 edited Apr 06 '21
On the wiki is this code at it does almost the same you posted
local result = turtle.detect()
if result then
print("There is a block in front of the turtle!")
else
print("There is no block in front of the turtle, only air or a liquid.")
end
2
u/SadieWopen Apr 05 '21
The code looks good, what happens when you use turtle.detect() in the Lua console?
Another thing to try is something like this:
while not turtle.detect() do print("nothing") endprint("something")just to see what is going on.