add new world events: on_block_broken, on_block_placed
This commit is contained in:
@@ -34,6 +34,7 @@ ContentLoader::ContentLoader(ContentPack* pack, ContentBuilder& builder)
|
||||
);
|
||||
stats = &runtime->getStatsWriteable();
|
||||
env = runtime->getEnvironment();
|
||||
this->runtime = runtime.get();
|
||||
builder.add(std::move(runtime));
|
||||
}
|
||||
|
||||
@@ -408,7 +409,7 @@ void ContentLoader::load() {
|
||||
|
||||
fs::path scriptFile = folder/fs::path("scripts/world.lua");
|
||||
if (fs::is_regular_file(scriptFile)) {
|
||||
scripting::load_world_script(env, pack->id, scriptFile);
|
||||
scripting::load_world_script(env, pack->id, scriptFile, runtime->worldfuncsset);
|
||||
}
|
||||
|
||||
if (!fs::is_regular_file(pack->getContentFile()))
|
||||
|
||||
@@ -14,7 +14,9 @@ struct BlockMaterial;
|
||||
struct ItemDef;
|
||||
struct EntityDef;
|
||||
struct ContentPack;
|
||||
|
||||
class ContentBuilder;
|
||||
class ContentPackRuntime;
|
||||
struct ContentPackStats;
|
||||
|
||||
namespace dynamic {
|
||||
@@ -24,6 +26,7 @@ namespace dynamic {
|
||||
|
||||
class ContentLoader {
|
||||
const ContentPack* pack;
|
||||
ContentPackRuntime* runtime;
|
||||
scriptenv env;
|
||||
ContentBuilder& builder;
|
||||
ContentPackStats* stats;
|
||||
|
||||
@@ -80,11 +80,18 @@ struct ContentPackStats {
|
||||
}
|
||||
};
|
||||
|
||||
struct world_funcs_set {
|
||||
bool onblockplaced : 1;
|
||||
bool onblockbroken : 1;
|
||||
};
|
||||
|
||||
class ContentPackRuntime {
|
||||
ContentPack info;
|
||||
ContentPackStats stats {};
|
||||
scriptenv env;
|
||||
public:
|
||||
world_funcs_set worldfuncsset {};
|
||||
|
||||
ContentPackRuntime(
|
||||
ContentPack info,
|
||||
scriptenv env
|
||||
|
||||
Reference in New Issue
Block a user