123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- -- 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/>.
- if minetest.get_mapgen_params().mgname ~= "v6" then
- minetest.register_abm({
- label = "Coral Propagation",
- nodenames = {"default:coral_brown", "default:coral_orange"},
- neighbors = {"group:water"},
- interval = 1800,
- chance = 900,
- 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 minetest.find_node_near(new_pos, 4, "group:sand")
- 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,
- })
- minetest.register_abm({
- label = "Coral Seeding",
- nodenames = {"group:water"},
- neighbors = {"group:sand"},
- interval = 3600,
- chance = 7200,
- catch_up = false,
- action = function(pos)
- if pos.y >= -8 and pos.y <= 0
- and not minetest.find_node_near(pos, 1, "air") then
- local new_node = {
- "default:coral_brown" ,
- "default:coral_orange",
- }
- minetest.set_node(pos, {name = new_node[math.random(2)]})
- end
- end,
- })
- end
|