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

Easy question

Started by trillilyy, 11 April 2013 - 03:35 PM
trillilyy #1
Posted 11 April 2013 - 05: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.
Dlcruz129 #2
Posted 11 April 2013 - 05: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
trillilyy #3
Posted 11 April 2013 - 05:51 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

Alright thank you
PixelToast #4
Posted 12 April 2013 - 08:08 AM
shorter version:

shell.run("turn","right","2")
Dlcruz129 #5
Posted 12 April 2013 - 08:13 AM
shorter version:

shell.run("turn","right","2")

Noes! Everything must be functions!
PixelToast #6
Posted 12 April 2013 - 08: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 .-.
TheOddByte #7
Posted 12 April 2013 - 09: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)