aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2017-08-11 21:16:09 +0200
committerparamat <mat.gregory@virginmedia.com>2017-08-13 21:39:08 +0100
commit2ea26e655d90be538c75aad5cc7ede2c5709179f (patch)
tree286ad2790a6c97048c85554e5ec9d43f022ddc25 /builtin
parent4381fe0a0a0921e6ba79c072045be2dc04be646a (diff)
downloadminetest-2ea26e655d90be538c75aad5cc7ede2c5709179f.tar.gz
minetest-2ea26e655d90be538c75aad5cc7ede2c5709179f.tar.bz2
minetest-2ea26e655d90be538c75aad5cc7ede2c5709179f.zip
Add slippery group for nodes (players/items slide)
Diffstat (limited to 'builtin')
-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,