forked from Mirrorlandia_minetest/minetest
Make add_entity return a reference to added entity (or nil)
This commit is contained in:
parent
cb88f7b6d4
commit
49b7055cb3
@ -152,7 +152,7 @@
|
||||
-- ^ Returns nil for unloaded area
|
||||
-- - get_node_light(pos, timeofday) -> 0...15 or nil
|
||||
-- ^ timeofday: nil = current time, 0 = night, 0.5 = day
|
||||
-- - add_entity(pos, name)
|
||||
-- - add_entity(pos, name): Returns ObjectRef or nil if failed
|
||||
-- - add_item(pos, itemstring)
|
||||
-- - add_rat(pos)
|
||||
-- - add_firefly(pos)
|
||||
|
@ -2352,8 +2352,13 @@ private:
|
||||
const char *name = luaL_checkstring(L, 3);
|
||||
// Do it
|
||||
ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, "");
|
||||
env->addActiveObject(obj);
|
||||
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…
Reference in New Issue
Block a user