mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
add ores
This commit is contained in:
parent
e590d06bb0
commit
e30e0083a0
5 changed files with 44 additions and 13 deletions
|
|
@ -212,5 +212,6 @@ void ContentLoader::loadGenerator(
|
|||
);
|
||||
}
|
||||
load_biomes(def, biomesFiles);
|
||||
def.script = scripting::load_generator(def, scriptFile);
|
||||
def.script = scripting::load_generator(
|
||||
def, scriptFile, pack->id+":generators/"+name+".files");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,8 @@ namespace scripting {
|
|||
|
||||
std::unique_ptr<GeneratorScript> load_generator(
|
||||
const GeneratorDef& def,
|
||||
const fs::path& file
|
||||
const fs::path& file,
|
||||
const std::string& dirPath
|
||||
);
|
||||
|
||||
/// @brief Load package-specific world script
|
||||
|
|
|
|||
|
|
@ -126,12 +126,20 @@ public:
|
|||
};
|
||||
|
||||
std::unique_ptr<GeneratorScript> scripting::load_generator(
|
||||
const GeneratorDef& def, const fs::path& file
|
||||
const GeneratorDef& def, const fs::path& file, const std::string& dirPath
|
||||
) {
|
||||
auto env = create_environment();
|
||||
auto L = lua::get_main_thread();
|
||||
lua::stackguard _(L);
|
||||
|
||||
lua::pushenv(L, *env);
|
||||
lua::pushstring(L, dirPath);
|
||||
lua::setfield(L, "__DIR__");
|
||||
lua::pushstring(L, dirPath + "/script.lua");
|
||||
lua::setfield(L, "__FILE__");
|
||||
|
||||
lua::pop(L);
|
||||
|
||||
if (fs::exists(file)) {
|
||||
lua::pop(L, load_script(*env, "generator", file));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue