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

Turtle Question

Started by Razputin, 21 August 2013 - 12:42 PM
Razputin #1
Posted 21 August 2013 - 02:42 PM
How do I get a turtle to take input and move that many times? Like if the user types in '7' and it moves 7 blocks?
Last1Here #2
Posted 21 August 2013 - 02:48 PM
This should do what you asked for


local tArgs = {...}

if #tArgs ~= 1 then
  print("Usage:")
  print("programName <blocks to move>")
else
  for i = 1, tAgs[1] do
    turtle.forward()
  end
  print("Moved "..tArgs[1].." blocks")
end

LBPHacker #3
Posted 21 August 2013 - 03:23 PM
-snip-
Nah, that'd be one too many moves.
for i = 1, tArgs[1] do -- doesn't start from 0
Last1Here #4
Posted 21 August 2013 - 08:44 PM
-snip-
Nah, that'd be one too many moves.
for i = 1, tArgs[1] do -- doesn't start from 0
Oh yeah haha (fixed)