Sol2: Pass arguments to script file?

Created on 15 Feb 2019  路  4Comments  路  Source: ThePhD/sol2

Related to #125 , how does one pass arguments to a script_file?

Documentation Examples

Most helpful comment

Copying the example from the related issue, I would assume its by doing this

sol::load_result fx = lua.load_file("script.lua");
fx("your", "arguments", "here");
-- script.lua
local a,b,c = ...
print(a,b,c)

Tested and seems to work fine.

Or did I misunderstand what passing arguments to script file meant?

All 4 comments

I don't think there's a well-defined way to do it.

Copying the example from the related issue, I would assume its by doing this

sol::load_result fx = lua.load_file("script.lua");
fx("your", "arguments", "here");
-- script.lua
local a,b,c = ...
print(a,b,c)

Tested and seems to work fine.

Or did I misunderstand what passing arguments to script file meant?

Well, today I learned something new. Neato.

I'll tag this as documentation, since it should probably be put in the docs.

Yup, every script/chunk you execute can be viewed as a function, it's pretty neat. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Koncord picture Koncord  路  4Comments

Erwsaym picture Erwsaym  路  4Comments

morsisko picture morsisko  路  3Comments

shohnwal picture shohnwal  路  10Comments

squeek502 picture squeek502  路  3Comments