Page 1 of 1

How to get arguments of lua:@myscript.lua 1,"two",3 ?

Posted: Thu 24 Jul, 2014 10:59
by galaxy_far_FAR_away
Hi everybody!

I'm such a noob in LUA/FAR macro system :Yahoo!:

So.

I like to call a LUA script-file "myscript.lua" from commandline (for example), and like to pass some arguments to it.

How I can get values of the passed arguments in "myscript.lua"?

I tried "arg[1]" which is nil and read whole luafar_manual.chm & macroapi_manual.en.chm + I read all the internet but I did not get an answer. Seems Google is not my friend? :cry:

Thanks for your help!

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Posted: Thu 24 Jul, 2014 11:11
by John Doe
arg is deprecated. Use vararg (...)
E.g.
  1. --myscript.lua
  2. far.Show(...)

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Posted: Thu 24 Jul, 2014 11:25
by Shmuel
You can get the arguments the following way: local a,b,c = ...
If you want them in a table: local arg = {...}
To find out how many arguments there are: local narg = select("#", ...)

Re: How to get arguments of lua:@myscript.lua 1,"two",3 ?

Posted: Thu 24 Jul, 2014 11:55
by galaxy_far_FAR_away
Thank You both for the light-speed answers!

OK, now I feel like I will do hypercomplex plugins for FAR :)