1
0
mirror of https://github.com/HybridDog/builtin_item.git synced 2024-12-23 01:10:26 +01:00

always search nodes if lots of objects are pushed by water

This commit is contained in:
HybridDog 2014-08-31 14:59:40 +02:00
parent f6629da1ba
commit c41e61e346

View File

@ -1,21 +1,24 @@
local time = tonumber(os.clock())+10 local time = tonumber(os.clock())+10
local lastpos = vector.zero or {x=0, y=0, z=0} local lastpos = vector.zero or {x=0, y=0, z=0}
local last_tab local last_tab
local always_test
local function get_nodes(pos) local function get_nodes(pos)
if not always_test then
local rnd_pos = vector.round(pos) local rnd_pos = vector.round(pos)
local t = tonumber(os.clock()) local t = tonumber(os.clock())
local tmp = vector.equals(rnd_pos, lastpos) if vector.equals(rnd_pos, lastpos)
if tmp
and t-time < 10 then and t-time < 10 then
return last_tab return last_tab
end end
if not tmp then
time = t+10
else
time = t time = t
end
lastpos = rnd_pos lastpos = rnd_pos
local near_objects = minetest.get_objects_inside_radius(pos, 1)
if #near_objects >= 2 then
always_test = true
minetest.after(10, function() always_test = false end)
end
end
local tab,n = {},1 local tab,n = {},1
for i = -1,1,2 do for i = -1,1,2 do
for _,p in pairs({ for _,p in pairs({
@ -26,7 +29,9 @@ local function get_nodes(pos)
n = n+1 n = n+1
end end
end end
if not always_test then
last_tab = tab last_tab = tab
end
return tab return tab
end end