2 posts
Posted 16 September 2012 - 01:52 AM
I'm using this code and every variant of it that I know, and it returns true no matter what constant I change. Could it be a bug?
turtle.detect()
if true then
print("true")
end
if false then
print("false")
end
The compare function is the same.
—-Edit:
Thanks CastleMan2000.
288 posts
Location
The trashcan where all Undertale trash is
Posted 16 September 2012 - 01:56 AM
That won't work because turtle.detect() would need to be in the if statements, or saved into a variable.
local detectBlock = turtle.detect()
if detectBlock == true then
print("true")
end
if detectBlock false then
print("false")
end
Or
if turtle.detect() then
print("true")
end
if not turtle.detect() then
print("false")
end
Same with turtle.compare().
504 posts
Location
Seattle, WA
Posted 16 September 2012 - 02:48 AM
Since turtle.detect() and turtle.compare() return a value, that you don't handle, you have no record of it in memory. True and false are constants, so when you check if either of them are themselves the conditional will be true.
288 posts
Location
The trashcan where all Undertale trash is
Posted 16 September 2012 - 03:27 AM
You're welcome. :)/>/>
2447 posts
Posted 16 September 2012 - 09:18 AM
Even better:
if turtle.detect() then
print("true")
else
print("false")
end