Skip to content

Commit 97f0bb0

Browse files
committedApr 5, 2013
Only enqueue falling nodes if they really want to fall
1 parent 1586cda commit 97f0bb0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
 

‎builtin/falling.lua

+9-8
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ end
142142
-- Some common functions
143143
--
144144

145-
function nodeupdate_single(p)
145+
function nodeupdate_single(p, delay)
146146
n = minetest.env:get_node(p)
147147
if minetest.get_node_group(n.name, "falling_node") ~= 0 then
148148
p_bottom = {x=p.x, y=p.y-1, z=p.z}
@@ -151,9 +151,13 @@ function nodeupdate_single(p)
151151
if minetest.registered_nodes[n_bottom.name] and
152152
(not minetest.registered_nodes[n_bottom.name].walkable or
153153
minetest.registered_nodes[n_bottom.name].buildable_to) then
154-
minetest.env:remove_node(p)
155-
spawn_falling_node(p, n.name)
156-
nodeupdate(p)
154+
if delay then
155+
minetest.after(0.1, nodeupdate_single, {x=p.x, y=p.y, z=p.z}, false)
156+
else
157+
minetest.env:remove_node(p)
158+
spawn_falling_node(p, n.name)
159+
nodeupdate(p)
160+
end
157161
end
158162
end
159163

@@ -170,14 +174,11 @@ function nodeupdate(p)
170174
p.x = math.floor(p.x+0.5)
171175
p.y = math.floor(p.y+0.5)
172176
p.z = math.floor(p.z+0.5)
173-
nodeupdate_single(p)
174177

175178
for x = -1,1 do
176179
for y = -1,1 do
177180
for z = -1,1 do
178-
if not (x==0 and y==0 and z==0) then
179-
minetest.after(0.1, nodeupdate_single, {x=p.x+x, y=p.y+y, z=p.z+z})
180-
end
181+
nodeupdate_single({x=p.x+x, y=p.y+y, z=p.z+z}, not (x==0 and y==0 and z==0))
181182
end
182183
end
183184
end

0 commit comments

Comments
 (0)
Please sign in to comment.