lua: uidocuments sub-environment
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace lua {
|
||||
bool rename(const std::string& from, const std::string& to);
|
||||
void remove(const std::string& name);;
|
||||
void createFuncs();
|
||||
int createEnvironment();
|
||||
int createEnvironment(int parent);
|
||||
void removeEnvironment(int id);
|
||||
const std::string storeAnonymous();
|
||||
};
|
||||
|
||||
@@ -91,8 +91,8 @@ wstringconsumer scripting::create_wstring_consumer(
|
||||
};
|
||||
}
|
||||
|
||||
std::unique_ptr<Environment> scripting::create_environment() {
|
||||
return std::make_unique<Environment>(state->createEnvironment());
|
||||
std::unique_ptr<Environment> scripting::create_environment(int parent) {
|
||||
return std::make_unique<Environment>(state->createEnvironment(parent));
|
||||
}
|
||||
|
||||
void scripting::on_world_load(Level* level, BlocksController* blocks) {
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace scripting {
|
||||
const std::string& file="<string>"
|
||||
);
|
||||
|
||||
std::unique_ptr<Environment> create_environment();
|
||||
std::unique_ptr<Environment> create_environment(int parent=0);
|
||||
|
||||
void on_world_load(Level* level, BlocksController* blocks);
|
||||
void on_world_save();
|
||||
|
||||
Reference in New Issue
Block a user