aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/scriptapi.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 4dcb66c77..6b850b19a 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -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)