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

Type program name with input

Started by Gamezdude, 09 June 2014 - 09:35 AM
Gamezdude #1
Posted 09 June 2014 - 11:35 AM
With the Turtle program 'Tunnel' you can type the program name (Tunnel) & input how far you want it to dig in the same line, like so…

Tunnel 12

How would I do it like so?

Input program:

User types in…

MoveTo 12

'MoveTo' is the program name and '12' is the user input.

I then want to set the input to a variable called 'UserInput'
newcat #2
Posted 09 June 2014 - 08:57 PM
In your moveTo program you need to set a variable like this:

tArgs = { ... }

Then you can get the first argument with that command:

firstArgumentVariable = tArgs[1]

If you want to check if the user specified enough arguments you can do that like that:

if #tArgs < 1 then
  print("Please specify distance!")
end