summaryrefslogtreecommitdiff
path: root/builtin/game/item_entity.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/game/item_entity.lua')
-rw-r--r--builtin/game/item_entity.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua
index 6425a10aa..190473ceb 100644
--- a/builtin/game/item_entity.lua
+++ b/builtin/game/item_entity.lua
@@ -4,11 +4,14 @@ function core.spawn_item(pos, item)
-- Take item in any format
local stack = ItemStack(item)
local obj = core.add_entity(pos, "__builtin:item")
- obj:get_luaentity():set_item(stack:to_string())
+ -- Don't use obj if it couldn't be added to the map.
+ if obj then
+ obj:get_luaentity():set_item(stack:to_string())
+ end
return obj
end
--- If item_entity_ttl is not set, enity will have default life time
+-- If item_entity_ttl is not set, enity will have default life time
-- Setting it to -1 disables the feature
local time_to_live = tonumber(core.setting_get("item_entity_ttl"))
@@ -81,7 +84,7 @@ core.register_entity(":__builtin:item", {
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
- if data.age then
+ if data.age then
self.age = data.age + dtime_s
else
self.age = dtime_s