aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_item.cpp')
-rw-r--r--src/script/cpp_api/s_item.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/script/cpp_api/s_item.cpp b/src/script/cpp_api/s_item.cpp
index d48a3aee9..3876272d7 100644
--- a/src/script/cpp_api/s_item.cpp
+++ b/src/script/cpp_api/s_item.cpp
@@ -69,7 +69,12 @@ bool ScriptApiItem::item_OnPlace(ItemStack &item,
// Call function
LuaItemStack::create(L, item);
- objectrefGetOrCreate(L, placer);
+
+ if (!placer)
+ lua_pushnil(L);
+ else
+ objectrefGetOrCreate(L, placer);
+
pushPointedThing(pointed);
PCALL_RES(lua_pcall(L, 3, 1, error_handler));
if (!lua_isnil(L, -1)) {