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

Help with command line arguments

Started by Arcane_Asylum, 30 July 2013 - 10:26 PM
Arcane_Asylum #1
Posted 31 July 2013 - 12:26 AM
Hey again, this time I am wondering how to add it so I can chose how many times to do something, like for tunneling that you put 'tunnel 5' and it repeats the tunnel code 5 times, I am wondering how I can do that so I don't have to put so much code in and make better mining programs! Thanks!
Lyqyd #2
Posted 31 July 2013 - 12:35 PM
Split into new topic.
UselessFlaw #3
Posted 31 July 2013 - 03:43 PM
EDIT: welp I feel like an idiot now. I misunderstood OPs question.
Lyqyd #4
Posted 31 July 2013 - 06:38 PM
That is not what he's asking. OP, have you read through the tunnel program to see how it does it?
Pyrodogg #5
Posted 01 August 2013 - 12:50 PM
The command line arguments are passed to your program as the special ellipses variable

...

You can reference them more easily by assigning them to a table

local args = {...}

Then use the value from the args table in a for loop


local times = args[1]

for i=1,times do
  --stuff
end
Lyqyd #6
Posted 01 August 2013 - 03:54 PM
Don't forget to tonumber() the argument, since they come in as strings.
Arcane_Asylum #7
Posted 01 August 2013 - 04:44 PM
Thanks :)/> and I looked through it just wasn't too sure what I was looking for since I had no idea where to start! But I got it now.