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

Program Arguments

Started by ztc0611, 04 June 2016 - 04:12 AM
ztc0611 #1
Posted 04 June 2016 - 06:12 AM
I am messing around with rednet for the first time and I was making a simple parroting program, where the words come from the arguments.


(The code is very simple but here it is)
Spoiler
  • local arg = ()
  • rednet.open("back")
  • rednet.send(9,arg)
  • rednet.close("back")

I was wondering how I could make it say every word if I said more than one word in the arguments when running the program.
Bomb Bloke #2
Posted 04 June 2016 - 06:19 AM
You'll need to lump all the arguments into a table. After that, it's easiest just to combine the whole thing with table.concat():

rednet.send( 9, table.concat( { ... }, " " ) )

Though I think ComputerCraft might automatically combine args for you if you stick them within quotes at the shell prompt.
Edited on 04 June 2016 - 04:20 AM
ztc0611 #3
Posted 04 June 2016 - 04:20 PM
Thanks!