mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Make add_entity return a reference to added entity (or nil)
This commit is contained in:
parent
cb88f7b6d4
commit
49b7055cb3
2 changed files with 8 additions and 3 deletions
|
@ -2352,8 +2352,13 @@ private:
|
|||
const char *name = luaL_checkstring(L, 3);
|
||||
// Do it
|
||||
ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, "");
|
||||
env->addActiveObject(obj);
|
||||
return 0;
|
||||
int objectid = env->addActiveObject(obj);
|
||||
// If failed to add, return nothing (reads as nil)
|
||||
if(objectid == 0)
|
||||
return 0;
|
||||
// Return ObjectRef
|
||||
objectref_get_or_create(L, obj);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// EnvRef:add_item(pos, inventorystring)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue