1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- -- 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_node("renew:compost", {
- description = "Compost",
- tiles = {"renew-compost.png"},
- groups = {crumbly=3, soil=1},
- sounds = default.node_sound_dirt_defaults(),
- })
- minetest.register_craft({
- output = "renew:compost",
- recipe = {
- {"group:leaves", "group:leaves", "group:leaves"},
- {"group:leaves", "group:leaves", "group:leaves"},
- {"group:leaves", "group:leaves", "group:leaves"},
- }
- })
- minetest.register_abm({
- label = "Compost rotting",
- nodenames = {"renew:compost"},
- neighbors = {"group:spreading_dirt_type", "group:flora", "flowers:mushroom_brown", "flowers:mushroom_red"},
- interval = 60,
- chance = 60,
- catch_up = true,
- action = function(pos)
- -- If the node above is not air, a plant, or a decomposer (a mushroom),
- -- decomposition cannot occur.
- local node_above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
- if node_above.name ~= "air"
- and node_above.name ~= "flowers:mushroom_brown"
- and node_above.name ~= "flowers:mushroom_red"
- and minetest.get_item_group(node_above.name, "flora") == 0 then
- return
- end
- -- Spreading dirt types will take over compost, converting it into
- -- their specific type of dirt.
- local spreader_pos = minetest.find_node_near(pos, 1, "group:spreading_dirt_type")
- if spreader_pos then
- local spreader = minetest.get_node(spreader_pos)
- minetest.set_node(pos, {name=spreader.name})
- return
- -- If a spreading dirt type isn't around, compost will simply decompose
- -- into regular dirt, but only if something is growing on it.
- elseif node_above.name ~= "air" then
- minetest.set_node(pos, {name="default:dirt"})
- end
- end,
- })
|