mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
ActiveObjectMgr fixes (#13560)
This commit is contained in:
parent
929a13a9a0
commit
11ec75c2ad
17 changed files with 204 additions and 153 deletions
|
@ -611,10 +611,12 @@ int ModApiEnv::l_add_entity(lua_State *L)
|
|||
const char *name = luaL_checkstring(L, 2);
|
||||
std::string staticdata = readParam<std::string>(L, 3, "");
|
||||
|
||||
ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, staticdata);
|
||||
int objectid = env->addActiveObject(obj);
|
||||
std::unique_ptr<ServerActiveObject> obj_u =
|
||||
std::make_unique<LuaEntitySAO>(env, pos, name, staticdata);
|
||||
auto obj = obj_u.get();
|
||||
int objectid = env->addActiveObject(std::move(obj_u));
|
||||
// If failed to add, return nothing (reads as nil)
|
||||
if(objectid == 0)
|
||||
if (objectid == 0)
|
||||
return 0;
|
||||
|
||||
// If already deleted (can happen in on_activate), return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue