update entity.spawn(...): now returns an Entity instead of id
This commit is contained in:
@@ -31,8 +31,8 @@ static int l_spawn(lua::State* L) {
|
||||
auto defname = lua::tostring(L, 1);
|
||||
auto& def = content->entities.require(defname);
|
||||
auto pos = lua::tovec3(L, 2);
|
||||
auto id = level->entities->spawn(def, pos);
|
||||
return lua::pushinteger(L, id);
|
||||
level->entities->spawn(def, pos);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_despawn(lua::State* L) {
|
||||
|
||||
@@ -271,6 +271,7 @@ scriptenv scripting::on_entity_spawn(const EntityDef& def, entityid_t eid, entit
|
||||
lua::pushenv(L, *entityenv);
|
||||
funcsset.on_grounded = lua::hasfield(L, "on_grounded");
|
||||
funcsset.on_despawn = lua::hasfield(L, "on_despawn");
|
||||
lua::pop(L, 2);
|
||||
return entityenv;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user