mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 02:51:49 +00:00
Add on_entity_spawned and on_entity_despawned events
This commit is contained in:
parent
936a5c8525
commit
518d5d5ae4
8 changed files with 75 additions and 1 deletions
|
|
@ -129,6 +129,8 @@ void scripting::on_entity_spawn(
|
|||
for (auto& component : components) {
|
||||
create_component(L, -1, *component, args, saved);
|
||||
}
|
||||
|
||||
scripting::on_entity_spawned(eid);
|
||||
}
|
||||
|
||||
static void process_entity_callback(
|
||||
|
|
@ -171,9 +173,13 @@ void scripting::on_entity_despawn(const Entity& entity) {
|
|||
entity, "on_despawn", &EntityFuncsSet::on_despawn, nullptr
|
||||
);
|
||||
auto L = lua::get_main_state();
|
||||
entityid_t uid = entity.getUID();
|
||||
|
||||
lua::get_from(L, "stdcomp", "remove_Entity", true);
|
||||
lua::pushinteger(L, entity.getUID());
|
||||
lua::pushinteger(L, uid);
|
||||
lua::call(L, 1, 0);
|
||||
|
||||
scripting::on_entity_despawned(uid);
|
||||
}
|
||||
|
||||
void scripting::on_entity_grounded(const Entity& entity, float force) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue