Browse Source

used soil wet/dry/base features of default, added dry_soil

master
TenPlus1 4 weeks ago
parent
commit
42404da9bb
4 changed files with 131 additions and 20 deletions
  1. +1
    -0
      README.md
  2. +12
    -1
      hoes.lua
  3. +1
    -1
      init.lua
  4. +117
    -18
      soil.lua

+ 1
- 0
README.md View File

@@ -13,6 +13,7 @@ This mod works by adding your new plant to the {growing=1} group and numbering t

### Changelog:

- 1.45 - Dirt and Hoes are more in line with default by using dry/wet/base options
- 1.44 - Added 'farming_stage_length' in mod settings for speed of crop growth, also thanks to TheDarkTiger for translation updates
- 1.43 - Scythe works on use instead of right-click, added seed=1 groups to actual seeds and seed=2 group for plantable food items.
- 1.42 - Soil needs water to be present within 3 blocks horizontally and 1 below to make wet soil, Jack 'o Lanterns now check protection, add chocolate block.


+ 12
- 1
hoes.lua View File

@@ -96,8 +96,19 @@ function farming.hoe_on_use(itemstack, user, pointed_thing, uses)
return
end

-- check if (wet) soil defined
local ndef = minetest.registered_nodes[under.name]
if ndef.soil == nil or ndef.soil.wet == nil or ndef.soil.dry == nil then
return
end

if minetest.is_protected(pt.under, user:get_player_name()) then
minetest.record_protection_violation(pt.under, user:get_player_name())
return
end

-- turn the node into soil, wear out item and play sound
minetest.set_node(pt.under, {name = "farming:soil"})
minetest.set_node(pt.under, {name = ndef.soil.dry})

minetest.sound_play("default_dig_crumbly", {pos = pt.under, gain = 0.5})



+ 1
- 1
init.lua View File

@@ -7,7 +7,7 @@

farming = {
mod = "redo",
version = "20200426",
version = "20200430",
path = minetest.get_modpath("farming"),
select = {
type = "fixed",


+ 117
- 18
soil.lua View File

@@ -1,40 +1,141 @@

local S = farming.intllib

-- add soil types to existing dirt blocks
minetest.override_item("default:dirt", {
soil = {
base = "default:dirt",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

minetest.override_item("default:dirt_with_grass", {
soil = {
base = "default:dirt_with_grass",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

minetest.override_item("default:dirt_with_dry_grass", {
soil = {
base = "default:dirt_with_dry_grass",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

minetest.override_item("default:dirt_with_rainforest_litter", {
soil = {
base = "default:dirt_with_rainforest_litter",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

minetest.override_item("default:dirt_with_coniferous_litter", {
soil = {
base = "default:dirt_with_coniferous_litter",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

minetest.override_item("default:dry_dirt", {
soil = {
base = "default:dry_dirt",
dry = "farming:dry_soil",
wet = "farming:dry_soil_wet"
}
})

minetest.override_item("default:dry_dirt_with_dry_grass", {
soil = {
base = "default:dry_dirt_with_dry_grass",
dry = "farming:dry_soil",
wet = "farming:dry_soil_wet"
}
})

-- normal soil
minetest.register_node("farming:soil", {
description = S("Soil"),
tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
drop = "default:dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 2},
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 2, field = 1},
sounds = default.node_sound_dirt_defaults(),
soil = {
base = "default:dirt",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

-- wet soil
minetest.register_node("farming:soil_wet", {
description = S("Wet Soil"),
tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
tiles = {
"default_dirt.png^farming_soil_wet.png",
"default_dirt.png^farming_soil_wet_side.png"},
drop = "default:dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 3},
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 3, field = 1},
sounds = default.node_sound_dirt_defaults(),
soil = {
base = "default:dirt",
dry = "farming:soil",
wet = "farming:soil_wet"
}
})

-- savanna soil
minetest.register_node("farming:dry_soil", {
description = S("Savanna Soil"),
tiles = {
"default_dry_dirt.png^farming_soil.png",
"default_dry_dirt.png"},
drop = "default:dry_dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 2, field = 1},
sounds = default.node_sound_dirt_defaults(),
soil = {
base = "default:dry_dirt",
dry = "farming:dry_soil",
wet = "farming:dry_soil_wet"
}
})

minetest.register_node("farming:dry_soil_wet", {
description = S("Wet Savanna Soil"),
tiles = {
"default_dry_dirt.png^farming_soil_wet.png",
"default_dry_dirt.png^farming_soil_wet_side.png"},
drop = "default:dry_dirt",
groups = {crumbly = 3, not_in_creative_inventory = 1, soil = 3, field = 1},
sounds = default.node_sound_dirt_defaults(),
soil = {
base = "default:dry_dirt",
dry = "farming:dry_soil",
wet = "farming:dry_soil_wet"
}
})

minetest.register_alias("farming:desert_sand_soil", "farming:soil")
minetest.register_alias("farming:desert_sand_soil_wet", "farming:soil_wet")
minetest.register_alias("farming:dry_soil", "farming:soil")
minetest.register_alias("farming:dry_soil_wet", "farming:soil_wet")
-- sand is not soil, change existing sand-soil to use dry soil
minetest.register_alias("farming:desert_sand_soil", "farming:dry_soil")
minetest.register_alias("farming:desert_sand_soil_wet", "farming:dry_soil_wet")

-- if water near soil then change to wet soil
minetest.register_abm({
nodenames = {"farming:soil", "farming:soil_wet"},
nodenames = {"group:field"},
interval = 15,
chance = 4,
catch_up = false,

action = function(pos, node)

local ndef = minetest.registered_nodes[node.name]
if not ndef or not ndef.soil or not ndef.soil.wet
or not ndef.soil.base or not ndef.soil.dry then return end

pos.y = pos.y + 1
local nn = minetest.get_node_or_nil(pos)
pos.y = pos.y - 1
@@ -54,24 +155,20 @@ minetest.register_abm({
return
end

-- check if there is water nearby and change soil accordingly
-- if minetest.find_node_near(pos, 3, {"group:water"}) then

-- check if water is within 3 nodes horizontally and 1 below
if #minetest.find_nodes_in_area(
{x = pos.x + 3, y = pos.y - 1, z = pos.z + 3},
{x = pos.x - 3, y = pos.y , z = pos.z - 3},
{"group:water"}) > 0 then

if node.name == "farming:soil" then
minetest.set_node(pos, {name = "farming:soil_wet"})
end
minetest.set_node(pos, {name = ndef.soil.wet})

elseif node.name == "farming:soil_wet" then
minetest.set_node(pos, {name = "farming:soil"})
elseif node.name == ndef.soil.wet then
minetest.set_node(pos, {name = ndef.soil.dry})

elseif node.name == "farming:soil" and minetest.get_item_group(nn, "plant") == 0 then
minetest.set_node(pos, {name = "default:dirt"})
elseif node.name == ndef.soil.dry
and minetest.get_item_group(nn, "plant") == 0 then
minetest.set_node(pos, {name = ndef.soil.base})
end
end,
})

Loading…
Cancel
Save