Cactus grows on dry dirt as well
This commit is contained in:
parent
eb610a90c1
commit
603436b3ce
@ -344,7 +344,7 @@ for _, npc_type_table in pairs(npc_types) do
|
||||
end
|
||||
elseif iname == "rp_default:cactus" then
|
||||
if npc_type == "farmer" then
|
||||
say(S("Cacti like to grow on sand. They are also a food source, if you're really desperate."), name)
|
||||
say(S("Cacti grow best on sand. They are also a food source, if you're really desperate."), name)
|
||||
elseif npc_type == "tavernkeeper" then
|
||||
say(S("This is the secret ingredient for my special drink. But don't tell anyone!"), name)
|
||||
else
|
||||
@ -409,7 +409,7 @@ for _, npc_type_table in pairs(npc_types) do
|
||||
end
|
||||
elseif iname == "rp_default:dry_dirt" then
|
||||
if npc_type == "farmer" then
|
||||
say(S("Nothing grows on dry dirt. Well, almost nothing."), name)
|
||||
say(S("Not much grows on dry dirt."), name)
|
||||
else
|
||||
say(S("This dirt is as dry as my jokes."), name)
|
||||
end
|
||||
|
@ -7,10 +7,14 @@ local SAPLING_RECHECK_TIME_MAX = 70
|
||||
|
||||
local GRAVITY = tonumber(minetest.settings:get("movement_gravity") or 9.81)
|
||||
|
||||
-- Maximum growth height of cactus, normally
|
||||
local CACTUS_MAX_HEIGHT = 4
|
||||
-- Maximum growth height of cactus, fertilized
|
||||
local CACTUS_MAX_HEIGHT_PLUS = 6
|
||||
-- Maximum growth height of cactus on dry dirt, normally
|
||||
local CACTUS_MAX_HEIGHT_DDIRT = 2
|
||||
-- Maximum growth height of cactus on dry dirt, fertilized
|
||||
local CACTUS_MAX_HEIGHT_DDIRT_PLUS = 3
|
||||
-- Maximum growth height of cactus on sand, normally
|
||||
local CACTUS_MAX_HEIGHT_SAND = 4
|
||||
-- Maximum growth height of cactus on sand, fertilized
|
||||
local CACTUS_MAX_HEIGHT_SAND_PLUS = 6
|
||||
-- Maximum growth height of thistle, normally
|
||||
local THISTLE_MAX_HEIGHT = 2
|
||||
-- Maximum growth height of thistle, fertilized
|
||||
@ -1005,22 +1009,32 @@ minetest.register_abm( -- cactus grows
|
||||
{
|
||||
label = "Growing cacti",
|
||||
nodenames = {"rp_default:cactus"},
|
||||
neighbors = {"group:sand"},
|
||||
neighbors = {"group:sand", "group:dry_dirt"},
|
||||
interval = 20,
|
||||
chance = 10,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
local name = minetest.get_node(pos).name
|
||||
if minetest.get_item_group(name, "sand") ~= 0 then
|
||||
local is_sand = minetest.get_item_group(name, "sand") ~= 0
|
||||
local is_ddirt = minetest.get_item_group(name, "dry_dirt") ~= 0
|
||||
if is_sand or is_ddirt then
|
||||
local fertilized = minetest.get_item_group(name, "plantable_fertilizer") == 1
|
||||
pos.y = pos.y+1
|
||||
local height = 0
|
||||
local maxh
|
||||
-- Determine maximum height. Bonus height on fertilized node
|
||||
if fertilized then
|
||||
maxh = CACTUS_MAX_HEIGHT_PLUS
|
||||
if is_sand then
|
||||
if fertilized then
|
||||
maxh = CACTUS_MAX_HEIGHT_SAND_PLUS
|
||||
else
|
||||
maxh = CACTUS_MAX_HEIGHT_SAND
|
||||
end
|
||||
else
|
||||
maxh = CACTUS_MAX_HEIGHT
|
||||
if fertilized then
|
||||
maxh = CACTUS_MAX_HEIGHT_DDIRT_PLUS
|
||||
else
|
||||
maxh = CACTUS_MAX_HEIGHT_DDIRT
|
||||
end
|
||||
end
|
||||
while minetest.get_node(pos).name == "rp_default:cactus" and height < maxh do
|
||||
height = height+1
|
||||
|
@ -708,7 +708,7 @@ minetest.register_node(
|
||||
"rp_default:cactus",
|
||||
{
|
||||
description = S("Cactus"),
|
||||
_tt_help = S("Grows on sand"),
|
||||
_tt_help = S("Grows on sand and dry dirt"),
|
||||
_tt_food = true,
|
||||
_tt_food_hp = 2,
|
||||
_tt_food_satiation = 5,
|
||||
|
Loading…
x
Reference in New Issue
Block a user