Jump to content




Taking command-line arguments?


3 replies to this topic

#1 B EZ MAN

  • New Members
  • 1 posts

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

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 10 March 2013 - 03:18 PM

Split into new topic. A title was provided for you.

#3 Greyhat

  • Members
  • 9 posts

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.

#4 JokerRH

  • Members
  • 147 posts

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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users