Jump to content




Possible Error


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

#1 PedroBarbosa

  • Members
  • 27 posts

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()


#2 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 19 December 2012 - 01:28 PM

Your turtle needs fuel. Add coal to slot one and in a code add turtle.refuel()

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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.

#4 PedroBarbosa

  • Members
  • 27 posts

Posted 19 December 2012 - 02:03 PM

View PostremiX, on 19 December 2012 - 01:28 PM, said:

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

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 19 December 2012 - 02:07 PM

Is that all the code in the program you're trying to run?

#6 PedroBarbosa

  • Members
  • 27 posts

Posted 19 December 2012 - 02:31 PM

View PostremiX, on 19 December 2012 - 02:07 PM, said:

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
?

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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.

#8 PedroBarbosa

  • Members
  • 27 posts

Posted 19 December 2012 - 02:44 PM

View PostLyqyd, on 19 December 2012 - 02:38 PM, said:

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

#9 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

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()


#10 civilwargeeky

  • Members
  • 393 posts

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


#11 PedroBarbosa

  • Members
  • 27 posts

Posted 19 December 2012 - 03:06 PM

It work! Thanks alot guys

#12 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 19 December 2012 - 06:04 PM

The second person's question in this topic has been moved to its own topic.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users