mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
content-pack specific variables PACK_ENV and PACK_ID
This commit is contained in:
parent
49fe2108d3
commit
617017d979
5 changed files with 19 additions and 3 deletions
|
|
@ -95,6 +95,16 @@ std::unique_ptr<Environment> scripting::create_environment(int parent) {
|
|||
return std::make_unique<Environment>(state->createEnvironment(parent));
|
||||
}
|
||||
|
||||
std::unique_ptr<Environment> scripting::create_pack_environment(const ContentPack& pack) {
|
||||
int id = state->createEnvironment(0);
|
||||
state->pushenv(id);
|
||||
state->pushvalue(-1);
|
||||
state->setfield("PACK_ENV");
|
||||
state->pushstring(pack.id);
|
||||
state->setfield("PACK_ID");
|
||||
return std::make_unique<Environment>(id);
|
||||
}
|
||||
|
||||
void scripting::on_world_load(Level* level, BlocksController* blocks) {
|
||||
scripting::level = level;
|
||||
scripting::content = level->content;
|
||||
|
|
@ -230,8 +240,6 @@ bool register_event(int env, const std::string& name, const std::string& id) {
|
|||
// remove previous name
|
||||
state->pushnil();
|
||||
state->setfield(name, -3);
|
||||
|
||||
std::cout << id << std::endl;
|
||||
// add new global name
|
||||
state->setglobal(id);
|
||||
state->pop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue