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

Taking command-line arguments?

Started by B EZ MAN, 10 March 2013 - 11:28 AM
B EZ MAN #1
Posted 10 March 2013 - 12:28 PM
Question:How can i input 2 things on 1 line like the tunnel program does "tunnel 10", it just seems more efficient
Lyqyd #2
Posted 10 March 2013 - 03:18 PM
Split into new topic. A title was provided for you.
Greyhat #3
Posted 10 March 2013 - 03:20 PM
What you're looking for is "args = {…}". for example, if you start your program as "DigDown 15"…


args = {…}
intDigDistance = args[1]

for i,intDigDistance do
turtle.digDown()
turtle.down()
end

That will send the turtle down 15 blocks. or if you instead type "DigDown 30", it'll go down 30.
JokerRH #4
Posted 11 March 2013 - 03:10 AM
It is the same as if you use shell.run(function, arg1, arg2, arg3, …, argn)
All these arguments are stored in the … and you can pack them into a table.

The CC startup screen should use the same function. So the first string you type in is your file and anything followed by this that is separated with a space will be passed over as an argument