From e29a905ab8b25cbd411af688564e9243c37624fc Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 10 Jan 2017 04:01:53 +0100 Subject: [PATCH] Add new groups for cultivation --- API.txt | 7 ++++++- mods/default/nodes.lua | 12 +++++++----- mods/farming/hoes.lua | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/API.txt b/API.txt index d29f439a1..ca83834c5 100644 --- a/API.txt +++ b/API.txt @@ -5,11 +5,16 @@ This document is a WORK IN PROGRESS. Currently, it only contains some information about the used groups. -Groups +Groups for interactions dig_by_water=1 Blocks with this group will drop when they are near flowing water + cultivatable=2 + Block will be turned into Farmland by using a hoe on it + cultivatable=1 + Block will be turned into Dirt by using a hoe on it + Groups (mostly) used for crafting recipes diff --git a/mods/default/nodes.lua b/mods/default/nodes.lua index e59f04cd7..3ae83244f 100644 --- a/mods/default/nodes.lua +++ b/mods/default/nodes.lua @@ -257,7 +257,7 @@ minetest.register_node("default:dirt_with_grass", { tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1}, + groups = {crumbly=3, soil=1, cultivatable=2}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, @@ -269,19 +269,21 @@ minetest.register_node("default:mycelium", { tiles = {"default_mycelium_top.png", "default_dirt.png", "default_mycelium_side.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1}, + -- TODO: Add mushroom soil group + groups = {crumbly=3, cultivatable=2}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, }), }) +-- TODO: Update for real snowy blocks minetest.register_node("default:dirt_with_snow", { description = "Dirt with Snow", tiles = {"default_snow.png", "default_dirt.png", "default_dirt.png^default_snow_side.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3}, + groups = {crumbly=3, cultivatable=2}, drop = 'default:dirt', sounds = default.node_sound_dirt_defaults({ footstep = {name="default_grass_footstep", gain=0.4}, @@ -293,7 +295,7 @@ minetest.register_node("default:dirt", { tiles = {"default_dirt.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1}, + groups = {crumbly=3, soil=1, cultivatable=2}, sounds = default.node_sound_dirt_defaults(), }) @@ -302,7 +304,7 @@ minetest.register_node("default:coarse_dirt", { tiles = {"default_coarse_dirt.png"}, is_ground_content = true, stack_max = 64, - groups = {crumbly=3, soil=1}, + groups = {crumbly=3, soil=1, cultivatable=1}, sounds = default.node_sound_dirt_defaults(), }) diff --git a/mods/farming/hoes.lua b/mods/farming/hoes.lua index d14e29d11..8bde35c2a 100644 --- a/mods/farming/hoes.lua +++ b/mods/farming/hoes.lua @@ -5,13 +5,13 @@ local function create_soil(pos, inv) local node = minetest.get_node(pos) local name = node.name local above = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}) - if name == "default:dirt" or name == "default:dirt_with_grass" or name == "default:mycelium" then + if minetest.get_item_group(name, "cultivatable") == 2 then if above.name == "air" then node.name = "farming:soil" minetest.set_node(pos, node) return true end - elseif name == "default:coarse_dirt" then + elseif minetest.get_item_group(name, "cultivatable") == 1 then if above.name == "air" then node.name = "default:dirt" minetest.set_node(pos, node)