This is to provide parameters to loading Actor definitions, in a way that
does not need to be explicitly propagated to nested definitions; I want
loading a sub-definition to remain a simple function call with no mandatory
(prescribed) parameters. This provides a general context to pass information
to Lua about what it's loading, such as LoadingScreen.
These are scoped to the running thread, unlike global variables. This prevents
possible threading problems.
All thread variables are scoped: set a variable, do something, unset it; when
finished, all thread variables are unset.
These are no longer available after load. By design, to use these later,
use upvalues:
local color = lua.GetVar("color");
return Def.Quad {
OnCommand=cmd(diffuse,color);
}
with Lua bindings: they couldn't read from disk, or render, or do anything
else potentially time-consuming, because that would hold the Lua lock,
preventing other threads from using it.
call.
- this means that nested calls which use Lua in unrelated, black boxed
ways (and so don't pass around an *L) don't share a stack; when you
Get a new state, you're guaranteed an empty stack, and like function
dispatches, you can use absolute stack indexes starting from 1
- we don't have to track stack counts to sanity check it; it always starts
at 0, so just check that the stack is empty again on Release
- we maintain a pool of states, so Get() is still fast; we typically create
only a couple states