forked from mtcontrib/bonemeal
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
d357709339
6
api.txt
6
api.txt
@ -15,7 +15,7 @@ Adding Crops
|
|||||||
------------
|
------------
|
||||||
|
|
||||||
bonemeal:add_crop({
|
bonemeal:add_crop({
|
||||||
{ nodename_start, growing_steps, seed_name }
|
{ nodename_start, growing_steps, seed_name, ignore_light }
|
||||||
})
|
})
|
||||||
|
|
||||||
This command is used to add new crops for bonemeal to work on.
|
This command is used to add new crops for bonemeal to work on.
|
||||||
@ -25,6 +25,7 @@ e.g.
|
|||||||
bonemeal:add_crop({
|
bonemeal:add_crop({
|
||||||
{"farming:cotton_", 8, "farming:seed_cotton"},
|
{"farming:cotton_", 8, "farming:seed_cotton"},
|
||||||
{"farming:wheat_", 8, "farming:seed_wheat"},
|
{"farming:wheat_", 8, "farming:seed_wheat"},
|
||||||
|
{"mymod:dark_wheat_", 8, "mymod:dark_wheat_seed", true}, -- can grow in darkness
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ Adding Saplings
|
|||||||
---------------
|
---------------
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{ sapling_node, function, soil_type[sand, dirt, nodename] }
|
{ sapling_node, function, soil_type["sand", "dirt", nodename, "group:"], ignore_light }
|
||||||
})
|
})
|
||||||
|
|
||||||
This command will add new saplings for bonemeal to grow on sand, soil or a
|
This command will add new saplings for bonemeal to grow on sand, soil or a
|
||||||
@ -41,6 +42,7 @@ specified node type.
|
|||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{"ethereal:palm_sapling", ethereal.grow_palm_tree, "soil"},
|
{"ethereal:palm_sapling", ethereal.grow_palm_tree, "soil"},
|
||||||
{"ethereal:palm_sapling", ethereal.grow_palm_tree, "sand"},
|
{"ethereal:palm_sapling", ethereal.grow_palm_tree, "sand"},
|
||||||
|
{"mymod:dark_tree", mymod.dark_tree, "group:soil", true}, -- can grow in darkness
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,3 +9,6 @@ flowers?
|
|||||||
dye?
|
dye?
|
||||||
ferns?
|
ferns?
|
||||||
dryplants?
|
dryplants?
|
||||||
|
df_trees?
|
||||||
|
df_farming?
|
||||||
|
df_primordial_items?
|
||||||
|
108
init.lua
108
init.lua
@ -86,7 +86,8 @@ minetest.after(0.1, function()
|
|||||||
if def.groups
|
if def.groups
|
||||||
and def.groups.flower
|
and def.groups.flower
|
||||||
and not node:find("waterlily")
|
and not node:find("waterlily")
|
||||||
and not node:find("xdecor:potted_") then
|
and not node:find("xdecor:potted_")
|
||||||
|
and not node:find("df_farming:") then
|
||||||
flowers[#flowers + 1] = node
|
flowers[#flowers + 1] = node
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -95,6 +96,8 @@ end)
|
|||||||
|
|
||||||
-- default biomes deco
|
-- default biomes deco
|
||||||
local deco = {
|
local deco = {
|
||||||
|
{"default:dirt", green_grass, flowers},
|
||||||
|
{"default:dirt_with_grass", green_grass, flowers},
|
||||||
{"default:dry_dirt", dry_grass, {}},
|
{"default:dry_dirt", dry_grass, {}},
|
||||||
{"default:dry_dirt_with_dry_grass", dry_grass, {}},
|
{"default:dry_dirt_with_dry_grass", dry_grass, {}},
|
||||||
{"default:dirt_with_dry_grass", dry_grass, flowers},
|
{"default:dirt_with_dry_grass", dry_grass, flowers},
|
||||||
@ -151,7 +154,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- sapling check
|
-- sapling check
|
||||||
local function check_sapling(pos, nodename)
|
local function check_sapling(pos, sapling_node, light_ok)
|
||||||
|
|
||||||
-- what is sapling placed on?
|
-- what is sapling placed on?
|
||||||
local under = minetest.get_node({
|
local under = minetest.get_node({
|
||||||
@ -165,36 +168,36 @@ local function check_sapling(pos, nodename)
|
|||||||
-- check list for sapling and function
|
-- check list for sapling and function
|
||||||
for n = 1, #saplings do
|
for n = 1, #saplings do
|
||||||
|
|
||||||
if saplings[n][1] == nodename then
|
if saplings[n][1] == sapling_node then
|
||||||
|
|
||||||
grow_on = saplings[n][3]
|
grow_on = saplings[n][3] or ""
|
||||||
|
|
||||||
-- sapling grows on top of specific node
|
-- backwards compatibility, add 'group:' to older grouping
|
||||||
if grow_on
|
if grow_on == "soil" or grow_on == "sand" then
|
||||||
and grow_on ~= "soil"
|
grow_on = "group:" .. grow_on
|
||||||
and grow_on ~= "sand"
|
end
|
||||||
and grow_on == under.name then
|
|
||||||
|
-- sapling grows on top of specific node group
|
||||||
|
if grow_on:find("group:") then
|
||||||
|
|
||||||
|
local group = grow_on:split(":")[2]
|
||||||
|
|
||||||
|
if minetest.get_item_group(under.name, group) > 0 then
|
||||||
can_grow = true
|
can_grow = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sapling grows on top of soil (default)
|
-- sapling grows on specific node
|
||||||
if can_grow == nil
|
elseif grow_on == under.name then
|
||||||
and (grow_on == nil or grow_on == "soil")
|
|
||||||
and minetest.get_item_group(under.name, "soil") > 0 then
|
|
||||||
can_grow = true
|
can_grow = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- sapling grows on top of sand
|
-- check if we can grow sapling at current light level
|
||||||
if can_grow == nil
|
if can_grow and (light_ok or saplings[n][4] == true) then
|
||||||
and grow_on == "sand"
|
|
||||||
and minetest.get_item_group(under.name, "sand") > 0 then
|
|
||||||
can_grow = true
|
|
||||||
end
|
|
||||||
|
|
||||||
-- check if we can grow sapling
|
|
||||||
if can_grow then
|
|
||||||
particle_effect(pos)
|
particle_effect(pos)
|
||||||
|
|
||||||
grow_tree(pos, saplings[n][2])
|
grow_tree(pos, saplings[n][2])
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -203,33 +206,50 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- crops check
|
-- crops check
|
||||||
local function check_crops(pos, nodename, strength)
|
local function check_crops(pos, nodename, strength, light_ok)
|
||||||
|
|
||||||
local mod, crop, stage, nod, def
|
local mod, crop, stage, nod, def
|
||||||
|
|
||||||
-- grow registered crops
|
-- grow registered crops
|
||||||
for n = 1, #crops do
|
for n = 1, #crops do
|
||||||
|
|
||||||
if nodename:find(crops[n][1])
|
-- check if crop can grow in current light level
|
||||||
or nodename == crops[n][3] then
|
if (light_ok or crops[n][4] == true)
|
||||||
|
and (nodename:find(crops[n][1])
|
||||||
|
or nodename == crops[n][3]) then
|
||||||
|
|
||||||
-- separate mod and node name
|
-- separate mod and node name
|
||||||
mod = nodename:split(":")[1] .. ":"
|
mod = nodename:split(":")[1] .. ":"
|
||||||
crop = nodename:split(":")[2]
|
crop = nodename:split(":")[2]
|
||||||
|
|
||||||
-- get stage number or set to 0 for seed
|
-- get stage number or set to 0 for seed
|
||||||
stage = tonumber( crop:split("_")[2] ) or 0
|
if crop:split("_")[3] then
|
||||||
|
stage = crop:split("_")[3]
|
||||||
|
else
|
||||||
|
stage = crop:split("_")[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
stage = tonumber(stage) or 0
|
||||||
|
|
||||||
stage = min(stage + strength, crops[n][2])
|
stage = min(stage + strength, crops[n][2])
|
||||||
|
|
||||||
-- check for place_param setting
|
-- check for place_param setting
|
||||||
nod = crops[n][1] .. stage
|
nod = crops[n][1] .. stage
|
||||||
def = minetest.registered_nodes[nod]
|
def = minetest.registered_nodes[nod]
|
||||||
|
|
||||||
|
-- make sure crop exists or isn't fully grown already
|
||||||
|
if not def or nod == nodename then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
def = def and def.place_param2 or 0
|
def = def and def.place_param2 or 0
|
||||||
|
|
||||||
minetest.set_node(pos, {name = nod, param2 = def})
|
minetest.set_node(pos, {name = nod, param2 = def})
|
||||||
|
|
||||||
particle_effect(pos)
|
particle_effect(pos)
|
||||||
|
|
||||||
|
minetest.get_node_timer(pos):start(10) -- restart any timers
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -242,33 +262,21 @@ local function check_soil(pos, nodename, strength)
|
|||||||
-- set radius according to strength
|
-- set radius according to strength
|
||||||
local side = strength - 1
|
local side = strength - 1
|
||||||
local tall = max(strength - 2, 0)
|
local tall = max(strength - 2, 0)
|
||||||
local floor
|
|
||||||
local groups = minetest.registered_items[nodename]
|
|
||||||
and minetest.registered_items[nodename].groups or {}
|
|
||||||
|
|
||||||
-- only place decoration on one type of surface
|
|
||||||
if groups.soil then
|
|
||||||
floor = {"group:soil"}
|
|
||||||
elseif groups.sand then
|
|
||||||
floor = {"group:sand"}
|
|
||||||
else
|
|
||||||
floor = {nodename}
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get area of land with free space above
|
-- get area of land with free space above
|
||||||
local dirt = minetest.find_nodes_in_area_under_air(
|
local dirt = minetest.find_nodes_in_area_under_air(
|
||||||
{x = pos.x - side, y = pos.y - tall, z = pos.z - side},
|
{x = pos.x - side, y = pos.y - tall, z = pos.z - side},
|
||||||
{x = pos.x + side, y = pos.y + tall, z = pos.z + side}, floor)
|
{x = pos.x + side, y = pos.y + tall, z = pos.z + side}, {nodename})
|
||||||
|
|
||||||
-- set default grass and decoration
|
-- set default grass and decoration
|
||||||
local grass = green_grass
|
local grass, decor
|
||||||
local decor = flowers
|
|
||||||
|
|
||||||
-- choose grass and decoration to use on dirt patch
|
-- choose grass and decoration to use on dirt patch
|
||||||
for n = 1, #deco do
|
for n = 1, #deco do
|
||||||
|
|
||||||
-- do we have a grass match?
|
-- do we have a grass match?
|
||||||
if nodename == deco[n][1] then
|
if nodename == deco[n][1] then
|
||||||
|
|
||||||
grass = deco[n][2] or {}
|
grass = deco[n][2] or {}
|
||||||
decor = deco[n][3] or {}
|
decor = deco[n][3] or {}
|
||||||
end
|
end
|
||||||
@ -321,7 +329,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- add to sapling list
|
-- add to sapling list
|
||||||
-- {sapling node, schematic or function name, "soil"|"sand"|specific_node}
|
-- {sapling node, schematic or function name, "soil"|"sand"|specific_node|"group:"}
|
||||||
--e.g. {"default:sapling", default.grow_new_apple_tree, "soil"}
|
--e.g. {"default:sapling", default.grow_new_apple_tree, "soil"}
|
||||||
|
|
||||||
function bonemeal:add_sapling(list)
|
function bonemeal:add_sapling(list)
|
||||||
@ -470,20 +478,20 @@ function bonemeal:on_use(pos, strength, node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- light check depending on strength (strength of 4 = no light needed)
|
-- light check depending on strength (strength of 4 = no light needed)
|
||||||
|
local light_ok = true
|
||||||
|
|
||||||
if (minetest.get_node_light(pos) or 0) < (12 - (strength * 3)) then
|
if (minetest.get_node_light(pos) or 0) < (12 - (strength * 3)) then
|
||||||
return
|
light_ok = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for tree growth if pointing at sapling
|
-- check for sapling growth
|
||||||
if (minetest.get_item_group(node.name, "sapling") > 0
|
if random(5 - strength) == 1
|
||||||
or node.name == "default:large_cactus_seedling")
|
and check_sapling(pos, node.name, light_ok) then
|
||||||
and random(5 - strength) == 1 then
|
|
||||||
check_sapling(pos, node.name)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check for crop growth
|
-- check for crop growth
|
||||||
if check_crops(pos, node.name, strength) then
|
if check_crops(pos, node.name, strength, light_ok) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -613,10 +621,10 @@ minetest.register_craft({
|
|||||||
recipe = {
|
recipe = {
|
||||||
{"group:bone", "group:bone", "group:bone"},
|
{"group:bone", "group:bone", "group:bone"},
|
||||||
{"bucket:bucket_water", "bucket:bucket_water", "bucket:bucket_water"},
|
{"bucket:bucket_water", "bucket:bucket_water", "bucket:bucket_water"},
|
||||||
{"bucket:bucket_water", "default:torch", "bucket:bucket_water"},
|
{"bucket:bucket_water", "default:torch", "bucket:bucket_water"}
|
||||||
},
|
},
|
||||||
replacements = {
|
replacements = {
|
||||||
{"bucket:bucket_water", "bucket:bucket_empty 5"},
|
{"bucket:bucket_water", "bucket:bucket_empty 5"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
2
mod.conf
2
mod.conf
@ -1,4 +1,4 @@
|
|||||||
name = bonemeal
|
name = bonemeal
|
||||||
depends = default
|
depends = default
|
||||||
optional_depends = intllib, lucky_block, farming, ethereal, moretrees, technic_worldgen, flowers, dye, ferns, dryplants
|
optional_depends = intllib, lucky_block, farming, ethereal, moretrees, technic_worldgen, flowers, dye, ferns, dryplants, df_trees, df_farming, df_primordial_items
|
||||||
description = Adds bone and bonemeal giving the ability to quickly grow plants and saplings.
|
description = Adds bone and bonemeal giving the ability to quickly grow plants and saplings.
|
||||||
|
112
mods.lua
112
mods.lua
@ -190,3 +190,115 @@ if minetest.get_modpath("dye") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if minetest.get_modpath("df_trees") then
|
||||||
|
|
||||||
|
local function spore_tree_fix(pos)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
df_trees.spawn_spore_tree(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fungiwood_fix(pos)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
df_trees.spawn_fungiwood(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function tunnel_fix(pos)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
df_trees.spawn_tunnel_tube(pos)
|
||||||
|
end
|
||||||
|
|
||||||
|
bonemeal:add_sapling({
|
||||||
|
{"df_trees:black_cap_sapling", df_trees.spawn_black_cap, "soil", true},
|
||||||
|
{"df_trees:fungiwood_sapling", fungiwood_fix, "soil", true},
|
||||||
|
{"df_trees:goblin_cap_sapling", df_trees.spawn_goblin_cap, "soil", true},
|
||||||
|
{"df_trees:spore_tree_sapling", spore_tree_fix, "soil", true},
|
||||||
|
{"df_trees:tower_cap_sapling", df_trees.spawn_tower_cap, "soil", true},
|
||||||
|
{"df_trees:tunnel_tube_sapling", tunnel_fix, "soil", true},
|
||||||
|
{"df_trees:nether_cap_sapling", df_trees.spawn_nether_cap, "group:nether_cap", true},
|
||||||
|
{"df_trees:nether_cap_sapling", df_trees.spawn_nether_cap, "group:cools_lava", true}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if minetest.get_modpath("df_farming") then
|
||||||
|
|
||||||
|
bonemeal:add_crop({
|
||||||
|
{"df_farming:cave_wheat_", 8, "df_farming:cave_wheat_seed", true},
|
||||||
|
{"df_farming:dimple_cup_", 4, "df_farming:dimple_cup_seed", true},
|
||||||
|
{"df_farming:pig_tail_", 8, "df_farming:pig_tail_seed", true},
|
||||||
|
{"df_farming:plump_helmet_", 4, "df_farming:plump_helmet_spawn", true},
|
||||||
|
{"df_farming:quarry_bush_", 5, "df_farming:quarry_bush_seed", true},
|
||||||
|
{"df_farming:sweet_pod_", 6, "df_farming:sweet_pod_seed", true}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
if minetest.get_modpath("df_primordial_items") then
|
||||||
|
|
||||||
|
local function mush_fix(pos)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
mapgen_helper.place_schematic(pos,
|
||||||
|
df_primordial_items.get_primordial_mushroom(), (math.random(1,4)-1)*90)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fern_fix(pos)
|
||||||
|
minetest.set_node(pos, {name = "air"})
|
||||||
|
local rotations = {0, 90, 180, 270}
|
||||||
|
mapgen_helper.place_schematic(pos,
|
||||||
|
df_primordial_items.get_fern_schematic(), rotations[math.random(1,#rotations)])
|
||||||
|
end
|
||||||
|
|
||||||
|
local function blood_fix(pos)
|
||||||
|
df_trees.grow_blood_thorn(pos, minetest.get_node(pos))
|
||||||
|
end
|
||||||
|
|
||||||
|
bonemeal:add_sapling({
|
||||||
|
{"df_primordial_items:jungle_mushroom_sapling",
|
||||||
|
df_primordial_items.spawn_jungle_mushroom, "soil", true},
|
||||||
|
{"df_primordial_items:jungletree_sapling",
|
||||||
|
df_primordial_items.spawn_jungle_tree, "soil", true},
|
||||||
|
{"df_primordial_items:mush_sapling", mush_fix, "soil", true},
|
||||||
|
{"df_primordial_items:fern_sapling", fern_fix, "soil", true},
|
||||||
|
{"df_trees:blood_thorn", blood_fix, "sand", true}
|
||||||
|
})
|
||||||
|
|
||||||
|
local jgrass = {
|
||||||
|
"df_primordial_items:jungle_grass_1",
|
||||||
|
"df_primordial_items:jungle_grass_2",
|
||||||
|
"df_primordial_items:jungle_grass_3",
|
||||||
|
"df_primordial_items:fern_1",
|
||||||
|
"df_primordial_items:fern_2",
|
||||||
|
"", "", "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
local jdeco = {
|
||||||
|
"df_primordial_items:jungle_mushroom_1",
|
||||||
|
"df_primordial_items:jungle_mushroom_2",
|
||||||
|
"df_primordial_items:glow_plant_1",
|
||||||
|
"df_primordial_items:glow_plant_2",
|
||||||
|
"df_primordial_items:glow_plant_3",
|
||||||
|
"", "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
bonemeal:add_deco({
|
||||||
|
{"df_primordial_items:dirt_with_jungle_grass", jgrass, jdeco}
|
||||||
|
})
|
||||||
|
|
||||||
|
local fgrass = {
|
||||||
|
"df_primordial_items:fungal_grass_1",
|
||||||
|
"df_primordial_items:fungal_grass_2",
|
||||||
|
"", "", "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
local fdeco = {
|
||||||
|
"df_primordial_items:glow_orb_stalks",
|
||||||
|
"df_primordial_items:glow_pods",
|
||||||
|
"", "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
bonemeal:add_deco({
|
||||||
|
{"df_primordial_items:dirt_with_mycelium", fgrass, fdeco}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user