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

Possible Error

Started by PedroBarbosa, 19 December 2012 - 12:06 PM
PedroBarbosa #1
Posted 19 December 2012 - 01:06 PM
Hey, im a newbie at lua and i got a possible error because turtle didnt move

This is the code


function down()
  if turtle.detectDown() ~= false then
	turtle.down()
  end
end

down()
remiX #2
Posted 19 December 2012 - 01:28 PM
Your turtle needs fuel. Add coal to slot one and in a code add turtle.refuel()
Lyqyd #3
Posted 19 December 2012 - 02:02 PM
Also, make sure to call the function. If you declare it, but never call it, the turtle would obviously never be told to move.
PedroBarbosa #4
Posted 19 December 2012 - 02:03 PM
Your turtle needs fuel. Add coal to slot one and in a code add turtle.refuel()
No… I have got fuel but turtle just ignore the program
remiX #5
Posted 19 December 2012 - 02:07 PM
Is that all the code in the program you're trying to run?
PedroBarbosa #6
Posted 19 December 2012 - 02:31 PM
Is that all the code in the program you're trying to run?
yes… should it be:

if turtle.detectDown() == false then
turtle.down()
end
?
Lyqyd #7
Posted 19 December 2012 - 02:38 PM
Either that, or just make sure to call the function. Which you seem to (now) do in your edited first post.
PedroBarbosa #8
Posted 19 December 2012 - 02:44 PM
Either that, or just make sure to call the function. Which you seem to (now) do in your edited first post.
I just forget to put on this topic the call of the function
Lyqyd #9
Posted 19 December 2012 - 02:46 PM
Oh, also, your original code would only have tried to move down if there were a block below it. Try this instead:


function down()
    if not turtle.detectDown() then
        turtle.down()
    end
end

down()
civilwargeeky #10
Posted 19 December 2012 - 02:55 PM
Yeah, like Lyqyd said, your program would make the turtle go down only if it DID detect a block.
You could use
 if not turtle.detectDown() then
like he said, or
 if turtle.detectDown() == false then 
or
 if turtle.detectDown() ~= true then 
or maybe even

--Pretty Risky here, I honestly don't know if this would work
if not turtle.detectDown() == true then
PedroBarbosa #11
Posted 19 December 2012 - 03:06 PM
It work! Thanks alot guys
Lyqyd #12
Posted 19 December 2012 - 06:04 PM
The second person's question in this topic has been moved to its own topic.