Merge branch 'main' into curl

This commit is contained in:
MihailRis
2024-11-22 11:11:56 +03:00
9 changed files with 101 additions and 51 deletions
+19 -4
View File
@@ -157,10 +157,25 @@ void scripting::process_post_runnables() {
}
}
void scripting::on_content_load(Content* content) {
scripting::content = content;
scripting::indices = content->getIndices();
auto L = lua::get_main_state();
if (lua::getglobal(L, "block")) {
const auto& materials = content->getBlockMaterials();
lua::createtable(L, 0, materials.size());
for (const auto& [name, material] : materials) {
lua::pushvalue(L, material->serialize());
lua::setfield(L, name);
}
lua::setfield(L, "materials");
lua::pop(L);
}
}
void scripting::on_world_load(LevelController* controller) {
scripting::level = controller->getLevel();
scripting::content = level->content;
scripting::indices = level->content->getIndices();
scripting::blocks = controller->getBlocksController();
scripting::controller = controller;
@@ -671,7 +686,7 @@ int scripting::get_values_on_stack() {
return lua::gettop(lua::get_main_state());
}
void scripting::load_block_script(
void scripting::load_content_script(
const scriptenv& senv,
const std::string& prefix,
const fs::path& file,
@@ -692,7 +707,7 @@ void scripting::load_block_script(
register_event(env, "on_blocks_tick", prefix + ".blockstick");
}
void scripting::load_item_script(
void scripting::load_content_script(
const scriptenv& senv,
const std::string& prefix,
const fs::path& file,
+4 -2
View File
@@ -45,6 +45,8 @@ namespace scripting {
void initialize(Engine* engine);
void on_content_load(Content* content);
bool register_event(
int env, const std::string& name, const std::string& id
);
@@ -128,7 +130,7 @@ namespace scripting {
/// @param file item script file
/// @param fileName script file path using the engine format
/// @param funcsset block callbacks set
void load_block_script(
void load_content_script(
const scriptenv& env,
const std::string& prefix,
const fs::path& file,
@@ -142,7 +144,7 @@ namespace scripting {
/// @param file item script file
/// @param fileName script file path using the engine format
/// @param funcsset item callbacks set
void load_item_script(
void load_content_script(
const scriptenv& env,
const std::string& prefix,
const fs::path& file,