[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Passing userdata to and from stack
- From: RLake@...
- Date: Mon, 14 Jul 2003 19:44:54 -0500
Another FAQ candidate, I think.
Bob: Lua scripts do not take arguments. So you have to work around that:
1) Make your script return a function which takes arguments. Call dofile
to get the function, and then call the function with your arguments (in
this case, your lightuserdata).
2) Make the arguments named global objects. Or create a global context
table, and make the arguments keys of that table. Or some combination of
the above.
3) Well, everything is a variation on those themes, actually. For example,
you could create a callback function, (as a global variable whose value is
a function) which returned information.
It really depends on how you want your script to interact with the
environment. If it is a configuration script, for example, it is usually
convenient to litter the global environment with named configuration
tables. On the other hand, solution one is often convenient for scripts
which create objects. But it is really a question of style, in the end.
Rici.