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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue