mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
lua: uidocuments sub-environment
This commit is contained in:
parent
4ce46f34bf
commit
e4f7315cc3
9 changed files with 31 additions and 16 deletions
|
|
@ -228,7 +228,7 @@ const std::string lua::LuaState::storeAnonymous() {
|
|||
return funcName;
|
||||
}
|
||||
|
||||
int lua::LuaState::createEnvironment() {
|
||||
int lua::LuaState::createEnvironment(int parent) {
|
||||
int id = nextEnvironment++;
|
||||
|
||||
// local env = {}
|
||||
|
|
@ -236,7 +236,13 @@ int lua::LuaState::createEnvironment() {
|
|||
|
||||
// setmetatable(env, {__index=_G})
|
||||
lua_createtable(L, 0, 1);
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
if (parent == 0 || true) {
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
} else {
|
||||
if (pushenv(parent) == 0) {
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
}
|
||||
}
|
||||
lua_setfield(L, -2, "__index");
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue