mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
moved interact from world to hud
This commit is contained in:
parent
55f30caa35
commit
3d301f13d7
3 changed files with 17 additions and 19 deletions
|
|
@ -127,7 +127,6 @@ struct WorldFuncsSet {
|
|||
bool onchunkremove;
|
||||
bool oninventoryopen;
|
||||
bool oninventoryclosed;
|
||||
bool oninventoryinteract;
|
||||
};
|
||||
|
||||
class ContentPackRuntime {
|
||||
|
|
|
|||
|
|
@ -540,22 +540,6 @@ void scripting::on_inventory_closed(const Player* player, const Inventory& inven
|
|||
}
|
||||
}
|
||||
|
||||
void scripting::on_inventory_interact(int invid, int slot, int action) {
|
||||
auto args = [invid, slot, action](lua::State* L) {
|
||||
lua::pushinteger(L, invid);
|
||||
lua::pushinteger(L, slot);
|
||||
lua::pushinteger(L, action);
|
||||
return 3;
|
||||
};
|
||||
for (auto& [packid, pack] : content->getPacks()) {
|
||||
if (pack->worldfuncsset.oninventoryinteract) {
|
||||
lua::emit_event(
|
||||
lua::get_main_state(), packid + ":.inventoryinteract", args
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::on_player_tick(Player* player, int tps) {
|
||||
auto args = [=](lua::State* L) {
|
||||
lua::pushinteger(L, player ? player->getId() : -1);
|
||||
|
|
@ -777,8 +761,6 @@ void scripting::load_world_script(
|
|||
register_event(env, "on_inventory_open", prefix + ":.inventoryopen");
|
||||
funcsset.oninventoryclosed =
|
||||
register_event(env, "on_inventory_closed", prefix + ":.inventoryclosed");
|
||||
funcsset.oninventoryinteract =
|
||||
register_event(env, "on_inventory_interact", prefix + ":.inventoryinteract");
|
||||
}
|
||||
|
||||
void scripting::load_layout_script(
|
||||
|
|
|
|||
|
|
@ -93,6 +93,22 @@ void scripting::on_frontend_close() {
|
|||
scripting::post_processing = nullptr;
|
||||
}
|
||||
|
||||
void scripting::on_inventory_interact(int invid, int slot, int action) {
|
||||
auto L = lua::get_main_state();
|
||||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
lua::emit_event(
|
||||
L,
|
||||
pack.id + ":.hudinventoryinteract",
|
||||
[&](lua::State* L) {
|
||||
lua::pushinteger(L, invid);
|
||||
lua::pushinteger(L, slot);
|
||||
lua::pushinteger(L, action);
|
||||
return 3;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void scripting::load_hud_script(
|
||||
const scriptenv& senv,
|
||||
const std::string& packid,
|
||||
|
|
@ -109,6 +125,7 @@ void scripting::load_hud_script(
|
|||
register_event(env, "on_hud_open", packid + ":.hudopen");
|
||||
register_event(env, "on_hud_render", packid + ":.hudrender");
|
||||
register_event(env, "on_hud_close", packid + ":.hudclose");
|
||||
register_event(env, "on_hud_inventory_interact", packid + ":.hudinventoryinteract");
|
||||
}
|
||||
|
||||
gui::PageLoaderFunc scripting::create_page_loader() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue