add data argument to container:add(...)
This commit is contained in:
parent
9befbb9795
commit
8e8cabf2d1
@ -83,8 +83,16 @@ static int l_container_add(lua::State* L) {
|
|||||||
}
|
}
|
||||||
auto xmlsrc = lua::require_string(L, 2);
|
auto xmlsrc = lua::require_string(L, 2);
|
||||||
try {
|
try {
|
||||||
|
auto env = docnode.document->getEnvironment();
|
||||||
|
if (lua::istable(L, 3)) {
|
||||||
|
env = create_environment(std::move(env));
|
||||||
|
lua::pushenv(L, *env);
|
||||||
|
lua::pushvalue(L, 3);
|
||||||
|
lua::setfield(L, "DATA");
|
||||||
|
lua::pop(L);
|
||||||
|
}
|
||||||
auto subnode = guiutil::create(
|
auto subnode = guiutil::create(
|
||||||
engine->getGUI(), xmlsrc, docnode.document->getEnvironment()
|
engine->getGUI(), xmlsrc, std::move(env)
|
||||||
);
|
);
|
||||||
node->add(subnode);
|
node->add(subnode);
|
||||||
UINode::getIndices(subnode, docnode.document->getMapWriteable());
|
UINode::getIndices(subnode, docnode.document->getMapWriteable());
|
||||||
|
|||||||
@ -154,6 +154,22 @@ std::unique_ptr<Process> scripting::start_coroutine(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] scriptenv scripting::create_environment(
|
||||||
|
const scriptenv& parent
|
||||||
|
) {
|
||||||
|
auto L = lua::get_main_state();
|
||||||
|
int id = lua::create_environment(L, (parent ? *parent : 0));
|
||||||
|
lua::pushenv(L, id);
|
||||||
|
lua::pushvalue(L, -1);
|
||||||
|
lua::setfield(L, "CUR_ENV");
|
||||||
|
|
||||||
|
lua::pop(L);
|
||||||
|
return std::shared_ptr<int>(new int(id), [=](int* id) { //-V508
|
||||||
|
lua::remove_environment(L, *id);
|
||||||
|
delete id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] scriptenv scripting::create_doc_environment(
|
[[nodiscard]] scriptenv scripting::create_doc_environment(
|
||||||
const scriptenv& parent, const std::string& name
|
const scriptenv& parent, const std::string& name
|
||||||
) {
|
) {
|
||||||
|
|||||||
@ -58,6 +58,7 @@ namespace scripting {
|
|||||||
|
|
||||||
scriptenv get_root_environment();
|
scriptenv get_root_environment();
|
||||||
scriptenv create_pack_environment(const ContentPack& pack);
|
scriptenv create_pack_environment(const ContentPack& pack);
|
||||||
|
scriptenv create_environment(const scriptenv& parent);
|
||||||
scriptenv create_doc_environment(
|
scriptenv create_doc_environment(
|
||||||
const scriptenv& parent, const std::string& name
|
const scriptenv& parent, const std::string& name
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user