[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Passing arguments to a chunk?
- From: Marc Balmer <marc@...>
- Date: Wed, 28 May 2014 09:30:33 +0200
Using loadfile() I can load a Lua chunk and assign it to a function:
env = {}
script = loadfile('test.lua', 'r', env)
Then using pcall() I can execute it:
pcall(script)
So far so good, but is there a way to pass an argument to a chunk? Using pcall, I can pass arguments like this
args = {}
args.data = 'Hello, world'
pcall(script, args)
But how can I access "args" from within the Lua chunk "test.lua"?