47 lines
1.6 KiB
Lua
47 lines
1.6 KiB
Lua
-- Renew mod for Minetest
|
|
-- Copyright © 2018 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 = "Coral Propagation",
|
|
nodenames = {"default:coral_brown", "default:coral_orange"},
|
|
neighbors = {"group:water"},
|
|
interval = 60,
|
|
chance = 10,
|
|
catch_up = true,
|
|
action = function(pos)
|
|
local new_pos = {
|
|
{x=pos.x,y=pos.y+1,z=pos.z},
|
|
{x=pos.x+1,y=pos.y,z=pos.z},
|
|
{x=pos.x,y=pos.y,z=pos.z+1},
|
|
{x=pos.x-1,y=pos.y,z=pos.z},
|
|
{x=pos.x,y=pos.y,z=pos.z-1},
|
|
{x=pos.x,y=pos.y-1,z=pos.z},
|
|
}
|
|
new_pos = new_pos[math.random(6)]
|
|
local old_node = minetest.get_node_or_nil(new_pos)
|
|
if new_pos.y >= -8 and new_pos.y <= 0 and old_node
|
|
and minetest.get_item_group(old_node.name, "water") > 0
|
|
and not minetest.find_node_near(new_pos, 1, "air") then
|
|
local new_node = {
|
|
"default:coral_brown" ,
|
|
"default:coral_orange",
|
|
}
|
|
minetest.set_node(new_pos, {name = new_node[math.random(2)]})
|
|
end
|
|
end,
|
|
})
|