prop = {
is_visible = true,
visual = "sprite",
- textures = {"unknown_item.png"},
- visual_size = {x=0.50, y=0.50}
+ textures = {"unknown_item.png"}
}
- if item_type == "node" then
+ if item_texture and item_texture ~= "" then
+ prop.visual = "sprite"
+ prop.textures = {item_texture}
+ prop.visual_size = {x=0.50, y=0.50}
+ else
prop.visual = "wielditem"
prop.textures = {itemname}
prop.visual_size = {x=0.20, y=0.20}
prop.automatic_rotate = math.pi * 0.25
- elseif item_texture and item_texture ~= "" then
- prop.visual = "sprite"
- prop.textures = {item_texture}
end
self.object:set_properties(prop)
end,
local p = self.object:getpos()
p.y = p.y - 0.3
local nn = minetest.env:get_node(p).name
- -- If node is not registered or node is walkably solid
- if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable then
+ -- If node is not registered or node is walkably solid and resting on nodebox
+ local v = self.object:getvelocity()
+ if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then
if self.physical_state then
self.object:setvelocity({x=0,y=0,z=0})
self.object:setacceleration({x=0, y=0, z=0})
on_punch = function(self, hitter)
if self.itemstring ~= '' then
- hitter:get_inventory():add_item("main", self.itemstring)
+ local left = hitter:get_inventory():add_item("main", self.itemstring)
+ if not left:is_empty() then
+ self.itemstring = left:to_string()
+ return
+ end
end
self.object:remove()
end,