56 lines
1.6 KiB
Lua
56 lines
1.6 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/>.
|
|
|
|
minetest.register_abm({
|
|
label = "Kelp Spread",
|
|
nodenames = {"default:sand_with_kelp"},
|
|
interval = 30,
|
|
chance = 50,
|
|
action = function(pos)
|
|
local seeds = {}
|
|
local potential_seeds = minetest.find_nodes_in_area({
|
|
x = pos.x - 5,
|
|
y = pos.y - 5,
|
|
z = pos.z - 5,
|
|
}, {
|
|
x = pos.x + 5,
|
|
y = pos.y + 5,
|
|
z = pos.z + 5,
|
|
}, "default:sand")
|
|
for _, seed_pos in next, potential_seeds do
|
|
local water = minetest.find_nodes_in_area({
|
|
x = seed_pos.x,
|
|
y = seed_pos.y + 1,
|
|
z = seed_pos.z,
|
|
}, {
|
|
x = seed_pos.x,
|
|
y = seed_pos.y + 6,
|
|
z = seed_pos.z,
|
|
}, "default:water_source")
|
|
if #water == 6 then
|
|
seeds[#seeds+1] = seed_pos
|
|
end
|
|
end
|
|
if #seeds > 0 then
|
|
minetest.set_node(seeds[math.random(#seeds)], {
|
|
name = "default:sand_with_kelp",
|
|
param2 = math.random(4, 6) * 16,
|
|
})
|
|
end
|
|
end,
|
|
})
|