Jump to content




Easy question


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

#1 trillilyy

  • Members
  • 4 posts

Posted 11 April 2013 - 04:35 PM

Ok here's an easy question I was wondering about

Can you do turtle.turnRights(2) instead of writing turtle.turnRight() twice ? because When I did it, the turtle only turn right once.

#2 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 11 April 2013 - 04:48 PM

No, but you can write a function to do it for you.

function right(times)
  for i = 1,times do
    turtle.turnRight()
  end
end


#3 trillilyy

  • Members
  • 4 posts

Posted 11 April 2013 - 04:51 PM

View PostDlcruz129, on 11 April 2013 - 04:48 PM, said:

No, but you can write a function to do it for you.

function right(times)
  for i = 1,times do
	turtle.turnRight()
  end
end

Alright thank you

#4 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 12 April 2013 - 07:08 AM

shorter version:
shell.run("turn","right","2")


#5 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 12 April 2013 - 07:13 AM

View PostPixelToast, on 12 April 2013 - 07:08 AM, said:

shorter version:
shell.run("turn","right","2")

Noes! Everything must be functions!

#6 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 12 April 2013 - 07:15 AM

function right(times)
shell.run("turn","right",tostring(times))
end
that better?
might aswell just run that single line instead of calling a function every time .-.

#7 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 12 April 2013 - 08:04 AM

I gotta agree with Dlcruz129 on this one.. It's not as good to use shell.run
since you can customize much more in functions..
function right(times)
 for i = 1, times do
    turtle.turnRight()
   end
end

--Then you just call it like this
right(2)






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users