46 lines
1.3 KiB
Lua
46 lines
1.3 KiB
Lua
-- Renew mod for Minetest
|
|
-- Copyright © 2020 Alex Yst <https://y.st./>
|
|
|
|
-- This program is free software; you can redistribute it and/or
|
|
-- modify it under the terms of the GNU Lesser General Public
|
|
-- License as published by the Free Software Foundation; either
|
|
-- version 2.1 of the License, or (at your option) any later version.
|
|
|
|
-- This software is distributed in the hope that it will be useful,
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
-- Lesser General Public License for more details.
|
|
|
|
-- You should have received a copy of the GNU Lesser General Public
|
|
-- License along with this program. If not, see
|
|
-- <https://www.gnu.org./licenses/>.
|
|
|
|
local nodenames = {
|
|
"default:marram_grass_1",
|
|
"default:marram_grass_2",
|
|
"default:marram_grass_3"
|
|
}
|
|
|
|
minetest.register_abm({
|
|
label = "Marram Grass Propagation",
|
|
nodenames = nodenames,
|
|
neighbors = {"default:sand"},
|
|
interval = 1800,
|
|
chance = 900,
|
|
catch_up = true,
|
|
action = function(pos)
|
|
local candidates = minetest.find_nodes_in_area_under_air({
|
|
x = pos.x - 1,
|
|
y = pos.y - 1,
|
|
z = pos.z - 1,
|
|
}, {
|
|
x = pos.x + 1,
|
|
y = pos.y + 1,
|
|
z = pos.z + 1,
|
|
}, "default:sand")
|
|
if #candidates > 0 then
|
|
minetest.set_node(math.random(#candidates), {name = nodenames[math.random(3)]})
|
|
end
|
|
end,
|
|
})
|