summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPilzAdam <pilzadam@minetest.net>2013-04-05 22:33:11 +0200
committerPilzAdam <pilzadam@minetest.net>2013-04-05 22:33:11 +0200
commit97f0bb03423b6d2e22058166b677e568c53d7567 (patch)
tree14a3bcc11e389b46f3bcb873d983db07df58839f
parent1586cdac53935cd4735162ad8337c269f0dfa718 (diff)
downloadminetest-97f0bb03423b6d2e22058166b677e568c53d7567.tar.gz
minetest-97f0bb03423b6d2e22058166b677e568c53d7567.tar.bz2
minetest-97f0bb03423b6d2e22058166b677e568c53d7567.zip
Only enqueue falling nodes if they really want to fall
-rw-r--r--builtin/falling.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/builtin/falling.lua b/builtin/falling.lua
index 5ae51e763..f6491991b 100644
--- a/builtin/falling.lua
+++ b/builtin/falling.lua
@@ -142,7 +142,7 @@ end
-- Some common functions
--
-function nodeupdate_single(p)
+function nodeupdate_single(p, delay)
n = minetest.env:get_node(p)
if minetest.get_node_group(n.name, "falling_node") ~= 0 then
p_bottom = {x=p.x, y=p.y-1, z=p.z}
@@ -151,9 +151,13 @@ function nodeupdate_single(p)
if minetest.registered_nodes[n_bottom.name] and
(not minetest.registered_nodes[n_bottom.name].walkable or
minetest.registered_nodes[n_bottom.name].buildable_to) then
- minetest.env:remove_node(p)
- spawn_falling_node(p, n.name)
- nodeupdate(p)
+ if delay then
+ minetest.after(0.1, nodeupdate_single, {x=p.x, y=p.y, z=p.z}, false)
+ else
+ minetest.env:remove_node(p)
+ spawn_falling_node(p, n.name)
+ nodeupdate(p)
+ end
end
end
@@ -170,14 +174,11 @@ function nodeupdate(p)
p.x = math.floor(p.x+0.5)
p.y = math.floor(p.y+0.5)
p.z = math.floor(p.z+0.5)
- nodeupdate_single(p)
for x = -1,1 do
for y = -1,1 do
for z = -1,1 do
- if not (x==0 and y==0 and z==0) then
- minetest.after(0.1, nodeupdate_single, {x=p.x+x, y=p.y+y, z=p.z+z})
- end
+ nodeupdate_single({x=p.x+x, y=p.y+y, z=p.z+z}, not (x==0 and y==0 and z==0))
end
end
end