forked from mtcontrib/bonemeal
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a200c9913e | |||
be412804df | |||
d6893aae07 | |||
81f36673d3 |
217
init.lua
217
init.lua
@ -1,50 +1,45 @@
|
|||||||
|
|
||||||
|
-- MineClonia / VoxeLibre check
|
||||||
|
|
||||||
|
local mcl = core.get_modpath("mcl_core")
|
||||||
|
|
||||||
|
-- global
|
||||||
|
|
||||||
bonemeal = {
|
bonemeal = {
|
||||||
item_list = {
|
item_list = {
|
||||||
bucket_water = "bucket:bucket_water",
|
bucket_water = mcl and "mcl_buckets:bucket_water" or "bucket:bucket_water",
|
||||||
bucket_empty = "bucket:bucket_empty",
|
bucket_empty = mcl and "mcl_buckets:bucker_empty" or "bucket:bucket_empty",
|
||||||
dirt = "default:dirt",
|
dirt = mcl and "mcl_core:dirt" or "default:dirt",
|
||||||
torch = "default:torch",
|
torch = mcl and "mcl_torches:torch" or "default:torch",
|
||||||
coral = "default:coral_skeleton"
|
coral = mcl and "mcl_ocean:dead_horn_coral_block" or "default:coral_skeleton"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- translation support and vars
|
||||||
|
|
||||||
|
local S = core.get_translator("bonemeal")
|
||||||
local a = bonemeal.item_list
|
local a = bonemeal.item_list
|
||||||
|
local path = core.get_modpath("bonemeal")
|
||||||
if minetest.get_modpath("mcl_core") then
|
|
||||||
|
|
||||||
a.bucket_water = "mcl_buckets:bucket_water"
|
|
||||||
a.bucket_empty = "mcl_buckets:bucker_empty"
|
|
||||||
a.dirt = "mcl_core:dirt"
|
|
||||||
a.torch = "mcl_torches:torch"
|
|
||||||
a.coral = "mcl_ocean:dead_horn_coral_block"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local path = minetest.get_modpath("bonemeal")
|
|
||||||
local min, max, random = math.min, math.max, math.random
|
local min, max, random = math.min, math.max, math.random
|
||||||
|
|
||||||
-- translation support
|
-- creative check helper
|
||||||
local S = minetest.get_translator("bonemeal")
|
|
||||||
|
|
||||||
-- creative check
|
local creative_mode_cache = core.settings:get_bool("creative_mode")
|
||||||
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
|
|
||||||
function bonemeal.is_creative(name)
|
function bonemeal.is_creative(name)
|
||||||
return creative_mode_cache or minetest.check_player_privs(name, {creative = true})
|
return creative_mode_cache or core.check_player_privs(name, {creative = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- API tables
|
||||||
|
|
||||||
local crops = {}
|
local crops = {}
|
||||||
local saplings = {}
|
local saplings = {}
|
||||||
local deco = {}
|
local deco = {}
|
||||||
|
|
||||||
--
|
-- particle effect
|
||||||
-- local functions
|
|
||||||
--
|
|
||||||
|
|
||||||
-- particles
|
|
||||||
local function particle_effect(pos)
|
local function particle_effect(pos)
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
core.add_particlespawner({
|
||||||
amount = 4,
|
amount = 4,
|
||||||
time = 0.15,
|
time = 0.15,
|
||||||
minpos = pos,
|
minpos = pos,
|
||||||
@ -62,38 +57,31 @@ local function particle_effect(pos)
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- tree type check
|
-- tree type check
|
||||||
|
|
||||||
local function grow_tree(pos, object)
|
local function grow_tree(pos, object)
|
||||||
|
|
||||||
if type(object) == "table" and object.axiom then
|
if type(object) == "table" and object.axiom then
|
||||||
|
|
||||||
-- grow L-system tree
|
core.remove_node(pos)
|
||||||
minetest.remove_node(pos)
|
core.spawn_tree(pos, object) -- grow L-system tree
|
||||||
minetest.spawn_tree(pos, object)
|
|
||||||
|
|
||||||
elseif type(object) == "string" and minetest.registered_nodes[object] then
|
elseif type(object) == "string" and core.registered_nodes[object] then
|
||||||
|
|
||||||
-- place node
|
core.set_node(pos, {name = object}) -- place node
|
||||||
minetest.set_node(pos, {name = object})
|
|
||||||
|
|
||||||
elseif type(object) == "function" then
|
elseif type(object) == "function" then
|
||||||
|
|
||||||
-- function
|
object(pos) -- execute function
|
||||||
object(pos)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- sapling check
|
-- sapling check
|
||||||
|
|
||||||
local function check_sapling(pos, sapling_node, strength, light_ok)
|
local function check_sapling(pos, sapling_node, strength, light_ok)
|
||||||
|
|
||||||
-- what is sapling placed on?
|
-- what is sapling placed on?
|
||||||
local under = minetest.get_node({
|
local under = core.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
|
||||||
x = pos.x,
|
|
||||||
y = pos.y - 1,
|
|
||||||
z = pos.z
|
|
||||||
})
|
|
||||||
|
|
||||||
local can_grow, grow_on
|
local can_grow, grow_on
|
||||||
|
|
||||||
@ -114,7 +102,7 @@ local function check_sapling(pos, sapling_node, strength, light_ok)
|
|||||||
|
|
||||||
local group = grow_on:split(":")[2]
|
local group = grow_on:split(":")[2]
|
||||||
|
|
||||||
if minetest.get_item_group(under.name, group) > 0 then
|
if core.get_item_group(under.name, group) > 0 then
|
||||||
can_grow = true
|
can_grow = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -138,8 +126,8 @@ local function check_sapling(pos, sapling_node, strength, light_ok)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- crops check
|
-- crops check
|
||||||
|
|
||||||
local function check_crops(pos, nodename, strength, light_ok)
|
local function check_crops(pos, nodename, strength, light_ok)
|
||||||
|
|
||||||
local mod, crop, stage, nod, def
|
local mod, crop, stage, nod, def
|
||||||
@ -169,7 +157,7 @@ local function check_crops(pos, nodename, strength, light_ok)
|
|||||||
|
|
||||||
-- 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 = core.registered_nodes[nod]
|
||||||
|
|
||||||
-- make sure crop exists or isn't fully grown already
|
-- make sure crop exists or isn't fully grown already
|
||||||
if not def or nod == nodename then
|
if not def or nod == nodename then
|
||||||
@ -178,19 +166,19 @@ local function check_crops(pos, nodename, strength, light_ok)
|
|||||||
|
|
||||||
def = def and def.place_param2 or 0
|
def = def and def.place_param2 or 0
|
||||||
|
|
||||||
minetest.set_node(pos, {name = nod, param2 = def})
|
core.set_node(pos, {name = nod, param2 = def})
|
||||||
|
|
||||||
particle_effect(pos)
|
particle_effect(pos)
|
||||||
|
|
||||||
minetest.get_node_timer(pos):start(10) -- restart any timers
|
core.get_node_timer(pos):start(10) -- restart any timers
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- check soil for specific decoration placement
|
-- check soil for specific decoration placement
|
||||||
|
|
||||||
local function check_soil(pos, nodename, strength)
|
local function check_soil(pos, nodename, strength)
|
||||||
|
|
||||||
-- set radius according to strength
|
-- set radius according to strength
|
||||||
@ -198,7 +186,7 @@ local function check_soil(pos, nodename, strength)
|
|||||||
local tall = max(strength - 2, 0)
|
local tall = max(strength - 2, 0)
|
||||||
|
|
||||||
-- 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 = core.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}, {nodename})
|
{x = pos.x + side, y = pos.y + tall, z = pos.z + side}, {nodename})
|
||||||
|
|
||||||
@ -247,43 +235,39 @@ local function check_soil(pos, nodename, strength)
|
|||||||
if nod and nod ~= "" then
|
if nod and nod ~= "" then
|
||||||
|
|
||||||
-- get crop param2 value
|
-- get crop param2 value
|
||||||
def = minetest.registered_nodes[nod]
|
def = core.registered_nodes[nod]
|
||||||
def = def and def.place_param2
|
def = def and def.place_param2
|
||||||
|
|
||||||
-- if param2 not preset then get from existing node
|
-- if param2 not preset then get from existing node
|
||||||
if not def then
|
if not def then
|
||||||
|
|
||||||
local node = minetest.get_node_or_nil(pos2)
|
local node = core.get_node_or_nil(pos2)
|
||||||
|
|
||||||
def = node and node.param2 or 0
|
def = node and node.param2 or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.set_node(pos2, {name = nod, param2 = def})
|
core.set_node(pos2, {name = nod, param2 = def})
|
||||||
end
|
end
|
||||||
|
|
||||||
particle_effect(pos2)
|
particle_effect(pos2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- helper function
|
-- helper function
|
||||||
|
|
||||||
local function use_checks(user, pointed_thing)
|
local function use_checks(user, pointed_thing)
|
||||||
|
|
||||||
-- make sure we use on node
|
-- make sure we use on node
|
||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then return false end
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get position and node info
|
-- get position and node info
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
local node = minetest.get_node(pos)
|
local node = core.get_node(pos)
|
||||||
local def = minetest.registered_items[node.name]
|
local def = core.registered_items[node.name]
|
||||||
local dirt = def and def.groups
|
local dirt = def and def.groups
|
||||||
|
|
||||||
-- does node have groups set
|
-- does node have groups set
|
||||||
if not dirt then
|
if not dirt then return false end
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if we're using on ground, move position up
|
-- if we're using on ground, move position up
|
||||||
if dirt.soil or dirt.sand or dirt.can_bonemeal then
|
if dirt.soil or dirt.sand or dirt.can_bonemeal then
|
||||||
@ -291,16 +275,14 @@ local function use_checks(user, pointed_thing)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- check if protected
|
-- check if protected
|
||||||
if minetest.is_protected(pos, user:get_player_name()) then
|
if core.is_protected(pos, user:get_player_name()) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--= Global functions
|
||||||
-- global functions
|
|
||||||
|
|
||||||
|
|
||||||
-- add to sapling list
|
-- add to sapling list
|
||||||
-- {sapling node, schematic or function name, "soil"|"sand"|specific_node|"group:"}
|
-- {sapling node, schematic or function name, "soil"|"sand"|specific_node|"group:"}
|
||||||
@ -313,10 +295,10 @@ function bonemeal:add_sapling(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- add to crop list to force grow
|
-- add to crop list to force grow
|
||||||
-- {crop name start_, growth steps, seed node (if required)}
|
-- {crop name start_, growth steps, seed node (if required)}
|
||||||
-- e.g. {"farming:wheat_", 8, "farming:seed_wheat"}
|
-- e.g. {"farming:wheat_", 8, "farming:seed_wheat"}
|
||||||
|
|
||||||
function bonemeal:add_crop(list)
|
function bonemeal:add_crop(list)
|
||||||
|
|
||||||
for n = 1, #list do
|
for n = 1, #list do
|
||||||
@ -324,12 +306,12 @@ function bonemeal:add_crop(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- add grass and flower/plant decoration for specific dirt types
|
-- add grass and flower/plant decoration for specific dirt types
|
||||||
-- {dirt_node, {grass_nodes}, {flower_nodes}
|
-- {dirt_node, {grass_nodes}, {flower_nodes}
|
||||||
-- e.g. {"default:dirt_with_dry_grass", dry_grass, flowers}
|
-- e.g. {"default:dirt_with_dry_grass", dry_grass, flowers}
|
||||||
-- if an entry already exists for a given dirt type, it will add new entries and all empty
|
-- if an entry already exists for a given dirt type, it will add new entries and all empty
|
||||||
-- entries, allowing to both add decorations and decrease their frequency.
|
-- entries, allowing to both add decorations and decrease their frequency.
|
||||||
|
|
||||||
function bonemeal:add_deco(list)
|
function bonemeal:add_deco(list)
|
||||||
|
|
||||||
for l = 1, #list do
|
for l = 1, #list do
|
||||||
@ -347,8 +329,7 @@ function bonemeal:add_deco(list)
|
|||||||
for _, entry in pairs(deco[n][2]) do
|
for _, entry in pairs(deco[n][2]) do
|
||||||
|
|
||||||
if extra == entry then
|
if extra == entry then
|
||||||
extra = false
|
extra = false ; break
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -366,8 +347,7 @@ function bonemeal:add_deco(list)
|
|||||||
for __, entry in pairs(deco[n][3]) do
|
for __, entry in pairs(deco[n][3]) do
|
||||||
|
|
||||||
if extra == entry then
|
if extra == entry then
|
||||||
extra = false
|
extra = false ; break
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -377,8 +357,7 @@ function bonemeal:add_deco(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
list[l] = false
|
list[l] = false ; break
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -388,9 +367,9 @@ function bonemeal:add_deco(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- definitively set a decration scheme
|
-- definitively set a decration scheme
|
||||||
-- this function will either add a new entry as is, or replace the existing one
|
-- this function will either add a new entry as is, or replace the existing one
|
||||||
|
|
||||||
function bonemeal:set_deco(list)
|
function bonemeal:set_deco(list)
|
||||||
|
|
||||||
for l = 1, #list do
|
for l = 1, #list do
|
||||||
@ -415,17 +394,15 @@ function bonemeal:set_deco(list)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- global on_use function for bonemeal
|
-- global on_use function for bonemeal
|
||||||
|
|
||||||
function bonemeal:on_use(pos, strength, node)
|
function bonemeal:on_use(pos, strength, node)
|
||||||
|
|
||||||
-- get node pointed at
|
-- get node pointed at
|
||||||
local node = node or minetest.get_node(pos)
|
local node = node or core.get_node(pos)
|
||||||
|
|
||||||
-- return if nothing there
|
-- return if nothing there
|
||||||
if node.name == "ignore" then
|
if node.name == "ignore" then return end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- make sure strength is between 1 and 4
|
-- make sure strength is between 1 and 4
|
||||||
strength = strength or 1
|
strength = strength or 1
|
||||||
@ -437,31 +414,25 @@ function bonemeal:on_use(pos, strength, node)
|
|||||||
|
|
||||||
default.grow_papyrus(pos, node)
|
default.grow_papyrus(pos, node)
|
||||||
|
|
||||||
particle_effect(pos)
|
particle_effect(pos) ; return true
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
elseif node.name == "default:cactus" then
|
elseif node.name == "default:cactus" then
|
||||||
|
|
||||||
default.grow_cactus(pos, node)
|
default.grow_cactus(pos, node)
|
||||||
|
|
||||||
particle_effect(pos)
|
particle_effect(pos) ; return true
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
elseif node.name == "default:dry_dirt" and strength == 1 then
|
elseif node.name == "default:dry_dirt" and strength == 1 then
|
||||||
|
|
||||||
minetest.set_node(pos, {name = "default:dry_dirt_with_dry_grass"})
|
core.set_node(pos, {name = "default:dry_dirt_with_dry_grass"})
|
||||||
|
|
||||||
particle_effect(pos)
|
particle_effect(pos) ; return true
|
||||||
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- grow grass and flowers
|
-- grow grass and flowers
|
||||||
if minetest.get_item_group(node.name, "soil") > 0
|
if core.get_item_group(node.name, "soil") > 0
|
||||||
or minetest.get_item_group(node.name, "sand") > 0
|
or core.get_item_group(node.name, "sand") > 0
|
||||||
or minetest.get_item_group(node.name, "can_bonemeal") > 0 then
|
or core.get_item_group(node.name, "can_bonemeal") > 0 then
|
||||||
|
|
||||||
check_soil(pos, node.name, strength)
|
check_soil(pos, node.name, strength)
|
||||||
|
|
||||||
@ -471,7 +442,7 @@ function bonemeal:on_use(pos, strength, node)
|
|||||||
-- 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
|
local light_ok = true
|
||||||
|
|
||||||
if (minetest.get_node_light(pos) or 0) < (12 - (strength * 3)) then
|
if (core.get_node_light(pos) or 0) < (12 - (strength * 3)) then
|
||||||
light_ok = nil
|
light_ok = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -486,14 +457,11 @@ function bonemeal:on_use(pos, strength, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--= Items
|
||||||
--
|
|
||||||
-- items
|
|
||||||
--
|
|
||||||
|
|
||||||
|
|
||||||
-- mulch (strength 1)
|
-- mulch (strength 1)
|
||||||
minetest.register_craftitem("bonemeal:mulch", {
|
|
||||||
|
core.register_craftitem("bonemeal:mulch", {
|
||||||
description = S("Mulch"),
|
description = S("Mulch"),
|
||||||
inventory_image = "bonemeal_mulch.png",
|
inventory_image = "bonemeal_mulch.png",
|
||||||
|
|
||||||
@ -517,9 +485,9 @@ minetest.register_craftitem("bonemeal:mulch", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- bonemeal (strength 2)
|
-- bonemeal (strength 2)
|
||||||
minetest.register_craftitem("bonemeal:bonemeal", {
|
|
||||||
|
core.register_craftitem("bonemeal:bonemeal", {
|
||||||
description = S("Bone Meal"),
|
description = S("Bone Meal"),
|
||||||
inventory_image = "bonemeal_item.png",
|
inventory_image = "bonemeal_item.png",
|
||||||
|
|
||||||
@ -543,9 +511,9 @@ minetest.register_craftitem("bonemeal:bonemeal", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- fertiliser (strength 3)
|
-- fertiliser (strength 3)
|
||||||
minetest.register_craftitem("bonemeal:fertiliser", {
|
|
||||||
|
core.register_craftitem("bonemeal:fertiliser", {
|
||||||
description = S("Fertiliser"),
|
description = S("Fertiliser"),
|
||||||
inventory_image = "bonemeal_fertiliser.png",
|
inventory_image = "bonemeal_fertiliser.png",
|
||||||
|
|
||||||
@ -569,28 +537,27 @@ minetest.register_craftitem("bonemeal:fertiliser", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
-- bone
|
-- bone
|
||||||
minetest.register_craftitem("bonemeal:bone", {
|
|
||||||
|
core.register_craftitem("bonemeal:bone", {
|
||||||
description = S("Bone"),
|
description = S("Bone"),
|
||||||
inventory_image = "bonemeal_bone.png",
|
inventory_image = "bonemeal_bone.png",
|
||||||
groups = {bone = 1}
|
groups = {bone = 1}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- gelatin powder
|
-- gelatin powder
|
||||||
minetest.register_craftitem("bonemeal:gelatin_powder", {
|
|
||||||
|
core.register_craftitem("bonemeal:gelatin_powder", {
|
||||||
description = S("Gelatin Powder"),
|
description = S("Gelatin Powder"),
|
||||||
inventory_image = "bonemeal_gelatin_powder.png",
|
inventory_image = "bonemeal_gelatin_powder.png",
|
||||||
groups = {food_gelatin = 1, flammable = 2}
|
groups = {food_gelatin = 1, flammable = 2}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
--= Recipes
|
||||||
--
|
|
||||||
-- crafting recipes
|
|
||||||
--
|
|
||||||
|
|
||||||
-- gelatin powder
|
-- gelatin powder
|
||||||
minetest.register_craft({
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:gelatin_powder 4",
|
output = "bonemeal:gelatin_powder 4",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:bone", "group:bone", "group:bone"},
|
{"group:bone", "group:bone", "group:bone"},
|
||||||
@ -603,7 +570,8 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- bonemeal (from bone)
|
-- bonemeal (from bone)
|
||||||
minetest.register_craft({
|
|
||||||
|
core.register_craft({
|
||||||
type = "cooking",
|
type = "cooking",
|
||||||
output = "bonemeal:bonemeal 2",
|
output = "bonemeal:bonemeal 2",
|
||||||
recipe = "group:bone",
|
recipe = "group:bone",
|
||||||
@ -611,22 +579,25 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- bonemeal (from player bones)
|
-- bonemeal (from player bones)
|
||||||
if minetest.settings:get_bool("bonemeal.disable_deathbones_recipe") ~= true then
|
|
||||||
|
|
||||||
minetest.register_craft({
|
if core.settings:get_bool("bonemeal.disable_deathbones_recipe") ~= true then
|
||||||
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:bone 2",
|
output = "bonemeal:bone 2",
|
||||||
recipe = {{"bones:bones"}}
|
recipe = {{"bones:bones"}}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- bonemeal (from coral skeleton)
|
-- bonemeal (from coral skeleton)
|
||||||
minetest.register_craft({
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:bonemeal 2",
|
output = "bonemeal:bonemeal 2",
|
||||||
recipe = {{a.coral}}
|
recipe = {{a.coral}}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- mulch
|
-- mulch
|
||||||
minetest.register_craft({
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:mulch 4",
|
output = "bonemeal:mulch 4",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:tree", "group:leaves", "group:leaves"},
|
{"group:tree", "group:leaves", "group:leaves"},
|
||||||
@ -635,7 +606,7 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "bonemeal:mulch",
|
output = "bonemeal:mulch",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"group:seed", "group:seed", "group:seed"},
|
{"group:seed", "group:seed", "group:seed"},
|
||||||
@ -645,15 +616,17 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- fertiliser
|
-- fertiliser
|
||||||
minetest.register_craft({
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:fertiliser 2",
|
output = "bonemeal:fertiliser 2",
|
||||||
recipe = {{"bonemeal:bonemeal", "bonemeal:mulch"}}
|
recipe = {{"bonemeal:bonemeal", "bonemeal:mulch"}}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- add bones to dirt
|
-- add bones to dirt
|
||||||
if minetest.registered_items[a.dirt] then
|
|
||||||
|
|
||||||
minetest.override_item(a.dirt, {
|
if core.registered_items[a.dirt] then
|
||||||
|
|
||||||
|
core.override_item(a.dirt, {
|
||||||
drop = {
|
drop = {
|
||||||
max_items = 1,
|
max_items = 1,
|
||||||
items = {
|
items = {
|
||||||
@ -670,10 +643,12 @@ if minetest.registered_items[a.dirt] then
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- add support for mods
|
-- add support for mods
|
||||||
|
|
||||||
dofile(path .. "/mods.lua")
|
dofile(path .. "/mods.lua")
|
||||||
|
|
||||||
-- lucky block support
|
-- lucky block support
|
||||||
if minetest.get_modpath("lucky_block") then
|
|
||||||
|
if core.get_modpath("lucky_block") then
|
||||||
dofile(path .. "/lucky_block.lua")
|
dofile(path .. "/lucky_block.lua")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
|
|
||||||
-- add lucky blocks
|
-- helper function
|
||||||
|
|
||||||
local function growy(pos, player)
|
local function growy(pos, player)
|
||||||
|
|
||||||
local dpos = minetest.find_node_near(pos, 1, "group:soil")
|
local dpos = core.find_node_near(pos, 1, "group:soil")
|
||||||
|
|
||||||
if dpos then
|
if dpos then
|
||||||
bonemeal:on_use(dpos, 5)
|
bonemeal:on_use(dpos, 5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- add lucky blocks
|
||||||
|
|
||||||
lucky_block:add_blocks({
|
lucky_block:add_blocks({
|
||||||
{"lig"},
|
{"lig"},
|
||||||
|
112
mods.lua
112
mods.lua
@ -1,21 +1,23 @@
|
|||||||
|
|
||||||
-- craft bones from animalmaterials into bonemeal
|
-- craft bones from animalmaterials into bonemeal
|
||||||
if minetest.get_modpath("animalmaterials") then
|
|
||||||
|
|
||||||
minetest.register_craft({
|
if core.get_modpath("animalmaterials") then
|
||||||
|
|
||||||
|
core.register_craft({
|
||||||
output = "bonemeal:bonemeal 2",
|
output = "bonemeal:bonemeal 2",
|
||||||
recipe = {{"animalmaterials:bone"}}
|
recipe = {{"animalmaterials:bone"}}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- default additions
|
||||||
|
|
||||||
if minetest.get_modpath("default") then
|
if core.get_modpath("default") then
|
||||||
|
|
||||||
-- saplings
|
-- saplings
|
||||||
|
|
||||||
local function pine_grow(pos)
|
local function pine_grow(pos)
|
||||||
|
|
||||||
if minetest.find_node_near(pos, 1,
|
if core.find_node_near(pos, 1,
|
||||||
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
|
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
|
||||||
|
|
||||||
default.grow_new_snowy_pine_tree(pos)
|
default.grow_new_snowy_pine_tree(pos)
|
||||||
@ -25,11 +27,11 @@ if minetest.get_modpath("default") then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function cactus_grow(pos)
|
local function cactus_grow(pos)
|
||||||
default.grow_cactus(pos, minetest.get_node(pos))
|
default.grow_cactus(pos, core.get_node(pos))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function papyrus_grow(pos)
|
local function papyrus_grow(pos)
|
||||||
default.grow_papyrus(pos, minetest.get_node(pos))
|
default.grow_papyrus(pos, core.get_node(pos))
|
||||||
end
|
end
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
@ -62,9 +64,10 @@ if minetest.get_modpath("default") then
|
|||||||
|
|
||||||
local flowers = {}
|
local flowers = {}
|
||||||
|
|
||||||
minetest.after(0.1, function()
|
-- add flowers from other mods
|
||||||
|
core.after(0.1, function()
|
||||||
|
|
||||||
for node, def in pairs(minetest.registered_nodes) do
|
for node, def in pairs(core.registered_nodes) do
|
||||||
|
|
||||||
if def.groups
|
if def.groups
|
||||||
and def.groups.flower
|
and def.groups.flower
|
||||||
@ -92,6 +95,7 @@ if minetest.get_modpath("default") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- default farming crops
|
||||||
|
|
||||||
if farming then
|
if farming then
|
||||||
|
|
||||||
@ -101,6 +105,7 @@ if farming then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- farming redo crops
|
||||||
|
|
||||||
if farming and farming.mod and farming.mod == "redo" then
|
if farming and farming.mod and farming.mod == "redo" then
|
||||||
|
|
||||||
@ -148,8 +153,9 @@ if farming and farming.mod and farming.mod == "redo" then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ethereal crops, saplings and grass
|
||||||
|
|
||||||
if minetest.get_modpath("ethereal") then
|
if core.get_modpath("ethereal") then
|
||||||
|
|
||||||
bonemeal:add_crop({
|
bonemeal:add_crop({
|
||||||
{"ethereal:strawberry_", 8},
|
{"ethereal:strawberry_", 8},
|
||||||
@ -174,7 +180,8 @@ if minetest.get_modpath("ethereal") then
|
|||||||
{"ethereal:sakura_sapling", ethereal.grow_sakura_tree, "soil"},
|
{"ethereal:sakura_sapling", ethereal.grow_sakura_tree, "soil"},
|
||||||
{"ethereal:lemon_tree_sapling", ethereal.grow_lemon_tree, "soil"},
|
{"ethereal:lemon_tree_sapling", ethereal.grow_lemon_tree, "soil"},
|
||||||
{"ethereal:olive_tree_sapling", ethereal.grow_olive_tree, "soil"},
|
{"ethereal:olive_tree_sapling", ethereal.grow_olive_tree, "soil"},
|
||||||
{"ethereal:basandra_bush_sapling", ethereal.grow_basandra_bush, "soil"}
|
{"ethereal:basandra_bush_sapling", ethereal.grow_basandra_bush, "soil"},
|
||||||
|
{"ethereal:mangrove_sapling", ethereal.grow_mangrove_tree, "soil"}
|
||||||
})
|
})
|
||||||
|
|
||||||
local grass = {"default:grass_3", "default:grass_4", "default:grass_5", ""}
|
local grass = {"default:grass_3", "default:grass_4", "default:grass_5", ""}
|
||||||
@ -191,17 +198,20 @@ if minetest.get_modpath("ethereal") then
|
|||||||
"ethereal:spore_grass", "ethereal:spore_grass", "", "", ""}},
|
"ethereal:spore_grass", "ethereal:spore_grass", "", "", ""}},
|
||||||
{"ethereal:jungle_dirt", grass, {"default:junglegrass", "", "", ""}},
|
{"ethereal:jungle_dirt", grass, {"default:junglegrass", "", "", ""}},
|
||||||
{"ethereal:grove_dirt", grass, {"ethereal:fern", "", "", ""}},
|
{"ethereal:grove_dirt", grass, {"ethereal:fern", "", "", ""}},
|
||||||
{"ethereal:bamboo_dirt", grass, {}}
|
{"ethereal:bamboo_dirt", grass, {}},
|
||||||
|
{"ethereal:mud", {"default:fern_1", "default:fern_2", "default:fern_3", "", "",
|
||||||
|
"default:grass_5", "default:junglegrass"}, {"ethereal:bamboo"}}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- moretrees saplings
|
||||||
|
|
||||||
if minetest.get_modpath("moretrees") then
|
if core.get_modpath("moretrees") then
|
||||||
|
|
||||||
-- special fir check for snow
|
-- special fir check for snow
|
||||||
local function fir_grow(pos)
|
local function fir_grow(pos)
|
||||||
|
|
||||||
if minetest.find_node_near(pos, 1,
|
if core.find_node_near(pos, 1,
|
||||||
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
|
{"default:snow", "default:snowblock", "default:dirt_with_snow"}) then
|
||||||
|
|
||||||
moretrees.grow_fir_snow(pos)
|
moretrees.grow_fir_snow(pos)
|
||||||
@ -228,23 +238,27 @@ if minetest.get_modpath("moretrees") then
|
|||||||
{"moretrees:rubber_tree_sapling", moretrees.spawn_rubber_tree_object, "soil"},
|
{"moretrees:rubber_tree_sapling", moretrees.spawn_rubber_tree_object, "soil"},
|
||||||
{"moretrees:fir_sapling", fir_grow, "soil"}
|
{"moretrees:fir_sapling", fir_grow, "soil"}
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
|
||||||
elseif minetest.get_modpath("technic_worldgen") then
|
-- technic rubber tree
|
||||||
|
|
||||||
|
if core.get_modpath("technic_worldgen") then
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{"moretrees:rubber_tree_sapling", technic.rubber_tree_model, "soil"}
|
{"moretrees:rubber_tree_sapling", technic.rubber_tree_model, "soil"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- caverealms mushroom
|
||||||
|
|
||||||
if minetest.get_modpath("caverealms") then
|
if core.get_modpath("caverealms") then
|
||||||
|
|
||||||
local fil = minetest.get_modpath("caverealms") .. "/schematics/shroom.mts"
|
local fil = core.get_modpath("caverealms") .. "/schematics/shroom.mts"
|
||||||
local add_shroom = function(pos)
|
local add_shroom = function(pos)
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = "air"})
|
core.swap_node(pos, {name = "air"})
|
||||||
|
|
||||||
minetest.place_schematic(
|
core.place_schematic(
|
||||||
{x = pos.x - 5, y = pos.y, z = pos.z - 5}, fil, 0, nil, false)
|
{x = pos.x - 5, y = pos.y, z = pos.z - 5}, fil, 0, nil, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -253,6 +267,7 @@ if minetest.get_modpath("caverealms") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- helper
|
||||||
|
|
||||||
local function y_func(grow_func)
|
local function y_func(grow_func)
|
||||||
return function(pos)
|
return function(pos)
|
||||||
@ -260,30 +275,38 @@ local function y_func(grow_func)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("ferns") then
|
-- ferns
|
||||||
|
|
||||||
|
if core.get_modpath("ferns") then
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{"ferns:sapling_giant_tree_fern", y_func(abstract_ferns.grow_giant_tree_fern), "soil"},
|
{"ferns:sapling_giant_tree_fern",
|
||||||
{"ferns:sapling_giant_tree_fern", y_func(abstract_ferns.grow_giant_tree_fern), "sand"},
|
y_func(abstract_ferns.grow_giant_tree_fern), "soil"},
|
||||||
{"ferns:sapling_tree_fern", y_func(abstract_ferns.grow_tree_fern), "soil"}
|
{"ferns:sapling_giant_tree_fern",
|
||||||
|
y_func(abstract_ferns.grow_giant_tree_fern), "sand"},
|
||||||
|
{"ferns:sapling_tree_fern",
|
||||||
|
y_func(abstract_ferns.grow_tree_fern), "soil"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
if minetest.get_modpath("dryplants") then
|
-- dryplants sapling
|
||||||
|
|
||||||
|
if core.get_modpath("dryplants") then
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{"dryplants:reedmace_sapling", y_func(abstract_dryplants.grow_reedmace), "soil"}
|
{"dryplants:reedmace_sapling", y_func(abstract_dryplants.grow_reedmace), "soil"}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- add bonemeal dyes
|
||||||
|
|
||||||
if minetest.get_modpath("dye") then
|
if core.get_modpath("dye") then
|
||||||
|
|
||||||
local bonemeal_dyes = {bonemeal = "white", fertiliser = "green", mulch = "brown"}
|
local bonemeal_dyes = {bonemeal = "white", fertiliser = "green", mulch = "brown"}
|
||||||
|
|
||||||
for mat, dye in pairs(bonemeal_dyes) do
|
for mat, dye in pairs(bonemeal_dyes) do
|
||||||
|
|
||||||
minetest.register_craft({
|
core.register_craft({
|
||||||
output = "dye:" .. dye .. " 4",
|
output = "dye:" .. dye .. " 4",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"bonemeal:" .. mat}
|
{"bonemeal:" .. mat}
|
||||||
@ -292,35 +315,36 @@ if minetest.get_modpath("dye") then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- df_trees saplings
|
||||||
|
|
||||||
if minetest.get_modpath("df_trees") then
|
if core.get_modpath("df_trees") then
|
||||||
|
|
||||||
local function spore_tree_fix(pos)
|
local function spore_tree_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_spore_tree(pos)
|
core.remove_node(pos) ; df_trees.spawn_spore_tree(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fungiwood_fix(pos)
|
local function fungiwood_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_fungiwood(pos)
|
core.remove_node(pos) ; df_trees.spawn_fungiwood(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tunnel_fix(pos)
|
local function tunnel_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_tunnel_tube(pos)
|
core.remove_node(pos) ; df_trees.spawn_tunnel_tube(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function black_cap_fix(pos)
|
local function black_cap_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_black_cap(pos)
|
core.remove_node(pos) ; df_trees.spawn_black_cap(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function goblin_cap_fix(pos)
|
local function goblin_cap_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_goblin_cap(pos)
|
core.remove_node(pos) ; df_trees.spawn_goblin_cap(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tower_cap_fix(pos)
|
local function tower_cap_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_tower_cap(pos)
|
core.remove_node(pos) ; df_trees.spawn_tower_cap(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nether_cap_fix(pos)
|
local function nether_cap_fix(pos)
|
||||||
minetest.remove_node(pos) ; df_trees.spawn_nether_cap(pos)
|
core.remove_node(pos) ; df_trees.spawn_nether_cap(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
@ -335,8 +359,9 @@ if minetest.get_modpath("df_trees") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- df_farming crops
|
||||||
|
|
||||||
if minetest.get_modpath("df_farming") then
|
if core.get_modpath("df_farming") then
|
||||||
|
|
||||||
bonemeal:add_crop({
|
bonemeal:add_crop({
|
||||||
{"df_farming:cave_wheat_", 8, "df_farming:cave_wheat_seed", true},
|
{"df_farming:cave_wheat_", 8, "df_farming:cave_wheat_seed", true},
|
||||||
@ -348,24 +373,25 @@ if minetest.get_modpath("df_farming") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- df_primordial saplings and plants
|
||||||
|
|
||||||
if minetest.get_modpath("df_primordial_items") then
|
if core.get_modpath("df_primordial_items") then
|
||||||
|
|
||||||
local function mush_fix(pos)
|
local function mush_fix(pos)
|
||||||
minetest.set_node(pos, {name = "air"})
|
core.set_node(pos, {name = "air"})
|
||||||
mapgen_helper.place_schematic(pos,
|
mapgen_helper.place_schematic(pos,
|
||||||
df_primordial_items.get_primordial_mushroom(), (math.random(4) - 1) * 90)
|
df_primordial_items.get_primordial_mushroom(), (math.random(4) - 1) * 90)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function fern_fix(pos)
|
local function fern_fix(pos)
|
||||||
minetest.set_node(pos, {name = "air"})
|
core.set_node(pos, {name = "air"})
|
||||||
local rotations = {0, 90, 180, 270}
|
local rotations = {0, 90, 180, 270}
|
||||||
mapgen_helper.place_schematic(pos,
|
mapgen_helper.place_schematic(pos,
|
||||||
df_primordial_items.get_fern_schematic(), rotations[math.random(#rotations)])
|
df_primordial_items.get_fern_schematic(), rotations[math.random(#rotations)])
|
||||||
end
|
end
|
||||||
|
|
||||||
local function blood_fix(pos)
|
local function blood_fix(pos)
|
||||||
df_trees.grow_blood_thorn(pos, minetest.get_node(pos))
|
df_trees.grow_blood_thorn(pos, core.get_node(pos))
|
||||||
end
|
end
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
@ -417,8 +443,9 @@ if minetest.get_modpath("df_primordial_items") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- everness saplings
|
||||||
|
|
||||||
if minetest.get_modpath("everness") then
|
if core.get_modpath("everness") then
|
||||||
|
|
||||||
bonemeal:add_sapling({
|
bonemeal:add_sapling({
|
||||||
{"everness:baobab_sapling", Everness.grow_baobab_tree, "soil"},
|
{"everness:baobab_sapling", Everness.grow_baobab_tree, "soil"},
|
||||||
@ -436,17 +463,18 @@ if minetest.get_modpath("everness") then
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- bush classic fruit
|
||||||
|
|
||||||
if minetest.get_modpath("bushes_classic") then
|
if core.get_modpath("bushes_classic") then
|
||||||
|
|
||||||
local function grow_bush(pos)
|
local function grow_bush(pos)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = core.get_meta(pos)
|
||||||
local bush_name = meta:get_string("bush_type")
|
local bush_name = meta:get_string("bush_type")
|
||||||
|
|
||||||
-- only change if meta found
|
-- only change if meta found
|
||||||
if meta and bush_name then
|
if meta and bush_name then
|
||||||
minetest.swap_node(pos, {name = "bushes:" .. bush_name .. "_bush"})
|
core.swap_node(pos, {name = "bushes:" .. bush_name .. "_bush"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user