automatic update
This commit is contained in:
parent
1952482797
commit
626dcaf7d8
60
init.lua
60
init.lua
@ -299,7 +299,56 @@ minetest.register_abm({
|
||||
end,
|
||||
})
|
||||
|
||||
local lq_rm_count --try to avoid stack overflow
|
||||
local function get_tab(pos)
|
||||
local taba = {pos}
|
||||
local tabb = {}
|
||||
local tab_avoid = {[pos.x.." "..pos.y.." "..pos.z] = true}
|
||||
local tab_done,num = {pos},2
|
||||
while taba[1]
|
||||
or tabb[1] do
|
||||
tabb = {}
|
||||
for _,p in pairs(taba) do
|
||||
for i = -1,1,2 do
|
||||
for _,p2 in pairs({
|
||||
{x=p.x+i, y=p.y, z=p.z},
|
||||
{x=p.x, y=p.y+i, z=p.z},
|
||||
{x=p.x, y=p.y, z=p.z+i},
|
||||
}) do
|
||||
local pstr = p2.x.." "..p2.y.." "..p2.z
|
||||
if not tab_avoid[pstr]
|
||||
and minetest.get_node(p2).name == "default:water_source" then
|
||||
tab_avoid[pstr] = true
|
||||
tab_done[num] = p2
|
||||
num = num+1
|
||||
table.insert(tabb, p2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
taba = {}
|
||||
for _,p in pairs(tabb) do
|
||||
for i = -1,1,2 do
|
||||
for _,p2 in pairs({
|
||||
{x=p.x+i, y=p.y, z=p.z},
|
||||
{x=p.x, y=p.y+i, z=p.z},
|
||||
{x=p.x, y=p.y, z=p.z+i},
|
||||
}) do
|
||||
local pstr = p2.x.." "..p2.y.." "..p2.z
|
||||
if not tab_avoid[pstr]
|
||||
and minetest.get_node(p2).name == "default:water_source" then
|
||||
tab_avoid[pstr] = true
|
||||
tab_done[num] = p2
|
||||
num = num+1
|
||||
table.insert(taba, p2)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return tab_done
|
||||
end
|
||||
|
||||
--[[local lq_rm_count --try to avoid stack overflow
|
||||
local function rm_lqud(pos, node)
|
||||
minetest.remove_node(pos)
|
||||
if lq_rm_count > 100 then
|
||||
@ -317,7 +366,7 @@ local function rm_lqud(pos, node)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end]]
|
||||
|
||||
minetest.register_node("extrablocks:seakiller", {
|
||||
description = "Sponge",
|
||||
@ -326,10 +375,13 @@ minetest.register_node("extrablocks:seakiller", {
|
||||
groups = {snappy=2, flammable=1},
|
||||
on_construct = function(pos)
|
||||
local t1 = os.clock()
|
||||
lq_rm_count = 0
|
||||
for _,p in pairs(get_tab(pos)) do
|
||||
minetest.remove_node(p)
|
||||
end
|
||||
--[[lq_rm_count = 0
|
||||
for _, nam in ipairs({"default:water_flowing", "default:water_source", "default:lava_source", "default:lava_flowing"}) do
|
||||
rm_lqud(pos, nam)
|
||||
end
|
||||
end]]
|
||||
print(string.format("[extrablocks] ("..pos.x..", "..pos.y..", "..pos.z..") liquids removed after: %.2fs", os.clock() - t1))
|
||||
end
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user