projects
/
oweals
/
minetest.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mainmenu: Remove space under mod list
[oweals/minetest.git]
/
builtin
/
game
/
item_entity.lua
diff --git
a/builtin/game/item_entity.lua
b/builtin/game/item_entity.lua
index 6425a10aab6cd7b6d4db8582b6e3878bdbf02c18..a66bf33d0e3935b58f70296bf7ea25f9556c5610 100644
(file)
--- 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")
-- 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
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"))
-- Setting it to -1 disables the feature
local time_to_live = tonumber(core.setting_get("item_entity_ttl"))
@@
-28,6
+31,7
@@
core.register_entity(":__builtin:item", {
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = false,
spritediv = {x = 1, y = 1},
initial_sprite_basepos = {x = 0, y = 0},
is_visible = false,
+ infotext = "",
},
itemstring = '',
},
itemstring = '',
@@
-47,6
+51,7
@@
core.register_entity(":__builtin:item", {
local c = s
local itemtable = stack:to_table()
local itemname = nil
local c = s
local itemtable = stack:to_table()
local itemname = nil
+ local description = ""
if itemtable then
itemname = stack:to_table().name
end
if itemtable then
itemname = stack:to_table().name
end
@@
-55,6
+60,7
@@
core.register_entity(":__builtin:item", {
if core.registered_items[itemname] then
item_texture = core.registered_items[itemname].inventory_image
item_type = core.registered_items[itemname].type
if core.registered_items[itemname] then
item_texture = core.registered_items[itemname].inventory_image
item_type = core.registered_items[itemname].type
+ description = core.registered_items[itemname].description
end
local prop = {
is_visible = true,
end
local prop = {
is_visible = true,
@@
-63,6
+69,7
@@
core.register_entity(":__builtin:item", {
visual_size = {x = s, y = s},
collisionbox = {-c, -c, -c, c, c, c},
automatic_rotate = math.pi * 0.5,
visual_size = {x = s, y = s},
collisionbox = {-c, -c, -c, c, c, c},
automatic_rotate = math.pi * 0.5,
+ infotext = description,
}
self.object:set_properties(prop)
end,
}
self.object:set_properties(prop)
end,
@@
-71,7
+78,8
@@
core.register_entity(":__builtin:item", {
return core.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
return core.serialize({
itemstring = self.itemstring,
always_collect = self.always_collect,
- age = self.age
+ age = self.age,
+ dropped_by = self.dropped_by
})
end,
})
end,
@@
-81,11
+89,12
@@
core.register_entity(":__builtin:item", {
if data and type(data) == "table" then
self.itemstring = data.itemstring
self.always_collect = data.always_collect
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
end
self.age = data.age + dtime_s
else
self.age = dtime_s
end
+ self.dropped_by = data.dropped_by
end
else
self.itemstring = staticdata
end
else
self.itemstring = staticdata
@@
-197,9
+206,10
@@
core.register_entity(":__builtin:item", {
end,
on_punch = function(self, hitter)
end,
on_punch = function(self, hitter)
- if self.itemstring ~= '' then
- local left = hitter:get_inventory():add_item("main", self.itemstring)
- if not left:is_empty() then
+ local inv = hitter:get_inventory()
+ if inv and self.itemstring ~= '' then
+ local left = inv:add_item("main", self.itemstring)
+ if left and not left:is_empty() then
self.itemstring = left:to_string()
return
end
self.itemstring = left:to_string()
return
end