Revert grass growth abm
The performance costs were too high, as we're under some ABM pressure on the new server...
This commit is contained in:
parent
dc347a3ffc
commit
74d42519b5
@ -1,8 +1,6 @@
|
||||
-- LUALOCALS < ---------------------------------------------------------
|
||||
local math, minetest, nodecore, pairs
|
||||
= math, minetest, nodecore, pairs
|
||||
local math_random
|
||||
= math.random
|
||||
local minetest, nodecore
|
||||
= minetest, nodecore
|
||||
-- LUALOCALS > ---------------------------------------------------------
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
@ -40,40 +38,17 @@ local function grassable(above)
|
||||
return ln >= 10
|
||||
end
|
||||
|
||||
local grasscost = 1000
|
||||
|
||||
nodecore.register_soaking_abm({
|
||||
nodecore.register_limited_abm({
|
||||
label = "Grass Spread",
|
||||
nodenames = {"group:grassable"},
|
||||
nodenames = {"group:soil"},
|
||||
neighbors = {grass},
|
||||
fieldname = "grassify",
|
||||
interval = 1,
|
||||
chance = 10,
|
||||
soakrate = function(pos)
|
||||
interval = 6,
|
||||
chance = 50,
|
||||
action = function(pos, node)
|
||||
if node.name == grass then return end
|
||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||
if not grassable(above) then return end
|
||||
return 10
|
||||
end,
|
||||
soakcheck = function(data, pos)
|
||||
if nodecore.near_unloaded(pos) then return end
|
||||
if data.total < grasscost then return end
|
||||
minetest.set_node(pos, {name = grass})
|
||||
local found = nodecore.find_nodes_around(pos, {"group:grassable"})
|
||||
if #found < 1 then return false end
|
||||
for i = 1, #found do
|
||||
local j = math_random(1, #found)
|
||||
found[i], found[j] = found[j], found[i]
|
||||
end
|
||||
for _, p in pairs(found) do
|
||||
p.y = p.y + 1
|
||||
if grassable(p) then
|
||||
p.y = p.y - 1
|
||||
nodecore.soaking_abm_push(p,
|
||||
"grassify", data.total - grasscost)
|
||||
return false
|
||||
end
|
||||
end
|
||||
return false
|
||||
return minetest.set_node(pos, {name = grass})
|
||||
end
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user