fix entity removal
This commit is contained in:
parent
d22948f45c
commit
f42cd9e567
@ -4,5 +4,6 @@ end
|
|||||||
|
|
||||||
function on_grounded()
|
function on_grounded()
|
||||||
entity.transform:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
|
entity.transform:set_rot(mat4.rotate({0, 1, 0}, math.random()*360))
|
||||||
|
print(stdcomp)
|
||||||
entity:despawn()
|
entity:despawn()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -40,10 +40,6 @@ return {
|
|||||||
return entity
|
return entity
|
||||||
end,
|
end,
|
||||||
remove_Entity = function(eid)
|
remove_Entity = function(eid)
|
||||||
local entity = entities[eid]
|
|
||||||
if entity and entity.on_despawn then
|
|
||||||
entity.on_despawn()
|
|
||||||
end
|
|
||||||
entities[eid] = nil;
|
entities[eid] = nil;
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@ -296,8 +296,12 @@ static bool process_entity_callback(
|
|||||||
bool scripting::on_entity_despawn(const EntityDef& def, const Entity& entity) {
|
bool scripting::on_entity_despawn(const EntityDef& def, const Entity& entity) {
|
||||||
const auto& script = entity.getScripting();
|
const auto& script = entity.getScripting();
|
||||||
if (script.funcsset.on_despawn) {
|
if (script.funcsset.on_despawn) {
|
||||||
return process_entity_callback(script.env, "on_despawn", nullptr);
|
process_entity_callback(script.env, "on_despawn", nullptr);
|
||||||
}
|
}
|
||||||
|
auto L = lua::get_main_thread();
|
||||||
|
lua::get_from(L, "stdcomp", "remove_Entity", true);
|
||||||
|
lua::pushinteger(L, entity.getUID());
|
||||||
|
lua::call(L, 1, 0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user