aboutsummaryrefslogtreecommitdiff
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.lua30
1 files changed, 21 insertions, 9 deletions
diff --git a/builtin/game/item_entity.lua b/builtin/game/item_entity.lua
index c0e36be2d..c1e3061d2 100644
--- a/builtin/game/item_entity.lua
+++ b/builtin/game/item_entity.lua
@@ -99,8 +99,8 @@ core.register_entity(":__builtin:item", {
self.itemstring = staticdata
end
self.object:set_armor_groups({immortal = 1})
- self.object:setvelocity({x = 0, y = 2, z = 0})
- self.object:setacceleration({x = 0, y = -10, z = 0})
+ self.object:set_velocity({x = 0, y = 2, z = 0})
+ self.object:set_acceleration({x = 0, y = -10, z = 0})
self:set_item(self.itemstring)
end,
@@ -177,8 +177,8 @@ core.register_entity(":__builtin:item", {
local in_unloaded = (node == nil)
if in_unloaded then
-- Don't infinetly fall into unloaded map
- self.object:setvelocity({x = 0, y = 0, z = 0})
- self.object:setacceleration({x = 0, y = 0, z = 0})
+ self.object:set_velocity({x = 0, y = 0, z = 0})
+ self.object:set_acceleration({x = 0, y = 0, z = 0})
self.physical_state = false
self.object:set_properties({physical = false})
return
@@ -186,7 +186,8 @@ core.register_entity(":__builtin:item", {
local nn = node.name
-- If node is not registered or node is walkably solid and resting on nodebox
local v = self.object:getvelocity()
- if not core.registered_nodes[nn] or core.registered_nodes[nn].walkable and v.y == 0 then
+ if not core.registered_nodes[nn] or (core.registered_nodes[nn].walkable and
+ core.get_item_group(nn, "slippery") == 0) and v.y == 0 then
if self.physical_state then
local own_stack = ItemStack(self.object:get_luaentity().itemstring)
-- Merge with close entities of the same item
@@ -199,17 +200,28 @@ core.register_entity(":__builtin:item", {
end
end
end
- self.object:setvelocity({x = 0, y = 0, z = 0})
- self.object:setacceleration({x = 0, y = 0, z = 0})
+ self.object:set_velocity({x = 0, y = 0, z = 0})
+ self.object:set_acceleration({x = 0, y = 0, z = 0})
self.physical_state = false
self.object:set_properties({physical = false})
end
else
if not self.physical_state then
- self.object:setvelocity({x = 0, y = 0, z = 0})
- self.object:setacceleration({x = 0, y = -10, z = 0})
+ self.object:set_velocity({x = 0, y = 0, z = 0})
+ self.object:set_acceleration({x = 0, y = -10, z = 0})
self.physical_state = true
self.object:set_properties({physical = true})
+ elseif minetest.get_item_group(nn, "slippery") ~= 0 then
+ if math.abs(v.x) < 0.2 and math.abs(v.z) < 0.2 then
+ self.object:set_velocity({x = 0, y = 0, z = 0})
+ self.object:set_acceleration({x = 0, y = 0, z = 0})
+ self.physical_state = false
+ self.object:set_properties({
+ physical = false
+ })
+ else
+ self.object:set_acceleration({x = -v.x, y = -10, z = -v.z})
+ end
end
end
end,