mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 11:01:49 +00:00
Added script-listener to packs loading
This commit is contained in:
parent
b5f5aeb5c6
commit
61625ffe00
5 changed files with 92 additions and 1 deletions
|
|
@ -334,12 +334,16 @@ void ContentLoader::load() {
|
|||
|
||||
fixPackIndices();
|
||||
|
||||
loadMainScript(*runtime);
|
||||
|
||||
auto folder = pack->folder;
|
||||
|
||||
builder.defaults = paths.readCombinedObject(
|
||||
EnginePaths::CONFIG_DEFAULTS.string()
|
||||
);
|
||||
|
||||
scripting::on_content_initialization();
|
||||
|
||||
// Load world generators
|
||||
io::path generatorsDir = folder / "generators";
|
||||
foreach_file(generatorsDir, [this](const io::path& file) {
|
||||
|
|
@ -462,6 +466,21 @@ void ContentLoader::reloadScript(const Content& content, ItemDef& item) {
|
|||
load_script(content, item);
|
||||
}
|
||||
|
||||
void ContentLoader::loadMainScript(ContentPackRuntime& runtime) {
|
||||
const auto& pack = runtime.getInfo();
|
||||
const auto& folder = pack.folder;
|
||||
io::path scriptFile = folder / "scripts/main.lua";
|
||||
if (io::is_regular_file(scriptFile)) {
|
||||
scripting::load_main_script(
|
||||
runtime.getEnvironment(),
|
||||
pack.id,
|
||||
scriptFile,
|
||||
pack.id + ":scripts/main.lua",
|
||||
runtime.mainfuncsset
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void ContentLoader::loadWorldScript(ContentPackRuntime& runtime) {
|
||||
const auto& pack = runtime.getInfo();
|
||||
const auto& folder = pack.folder;
|
||||
|
|
@ -478,6 +497,7 @@ void ContentLoader::loadWorldScript(ContentPackRuntime& runtime) {
|
|||
}
|
||||
|
||||
void ContentLoader::loadScripts(Content& content) {
|
||||
scripting::on_content_loading();
|
||||
load_scripts(content, content.blocks);
|
||||
load_scripts(content, content.items);
|
||||
|
||||
|
|
@ -486,7 +506,7 @@ void ContentLoader::loadScripts(Content& content) {
|
|||
const auto& pack = runtime->getInfo();
|
||||
const auto& folder = pack.folder;
|
||||
|
||||
// Load main world script
|
||||
// Load world script
|
||||
loadWorldScript(*runtime);
|
||||
|
||||
// Load entity components
|
||||
|
|
@ -501,6 +521,8 @@ void ContentLoader::loadScripts(Content& content) {
|
|||
);
|
||||
});
|
||||
}
|
||||
|
||||
scripting::on_content_loaded();
|
||||
}
|
||||
|
||||
void ContentLoader::loadResources(ResourceType type, const dv::value& list) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue