fix entities.spawn in coroutines

This commit is contained in:
MihailRis
2025-03-27 08:50:42 +03:00
parent 35a6985d7e
commit bbe5688a53
3 changed files with 12 additions and 3 deletions
+4 -2
View File
@@ -63,8 +63,10 @@ static int l_spawn(lua::State* L) {
if (lua::gettop(L) > 2) {
args = lua::tovalue(L, 3);
}
level->entities->spawn(def, pos, std::move(args));
return 1;
entityid_t id = level->entities->spawn(def, pos, std::move(args));
lua::get_from(L, "entities", "get", true);
lua::pushinteger(L, id);
return lua::call_nothrow(L, 1);
}
static int l_despawn(lua::State* L) {
+1
View File
@@ -549,6 +549,7 @@ void scripting::on_entity_spawn(
const dv::value& saved
) {
auto L = lua::get_main_state();
lua::stackguard guard(L);
lua::requireglobal(L, STDCOMP);
if (lua::getfield(L, "new_Entity")) {
lua::pushinteger(L, eid);