How can I pass parameters to a Lua file when loading it from another Lua file?

前端 未结 2 1336
故里飘歌
故里飘歌 2020-12-15 08:05

I need some help on parsing the Command Line for a lua file. I am executing a lua file and that lua file has a command \"dofile(2nd.lua-file)\", but, I want to pass some arg

2条回答
  •  我在风中等你
    2020-12-15 08:53

    Try this. In file `a.lua':

    assert(loadfile("b.lua"))(10,20,30)

    In file b.lua:

    local a,b,c=...

    or

    local arg={...}

    The arguments to b.lua are received as varargs, hence the ....

提交回复
热议问题