1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- -- 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_setting("mgname") ~= "v6" then
- local coral_colour = {
- "default:coral_brown" ,
- "default:coral_orange",
- }
- local rooted_coral_colour = {
- "default:coral_cyan",
- "default:coral_green",
- "default:coral_pink",
- }
- 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
- minetest.set_node(new_pos, {name = coral_colour[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
- minetest.set_node(pos, {name = coral_colour[math.random(2)]})
- end
- end,
- })
- minetest.register_abm({
- label = "Rooted Coral Propagation",
- nodenames = {"default:coral_skeleton"},
- neighbors = {"group:water"},
- interval = 1800,
- chance = 900,
- catch_up = true,
- action = function(pos)
- if minetest.get_node({
- x = pos.x,
- y = pos.y + 1,
- z = pos.z,
- }).name == "default:water_source" then
- minetest.set_node(new_pos, {
- name = rooted_coral_colour[math.random(3)],
- })
- end
- end,
- })
- end
|