Merge remote-tracking branch 'upstream/master'

This commit is contained in:
bri cassa 2023-06-05 22:55:07 +02:00
commit 0a9668fff1
16 changed files with 240 additions and 180 deletions

119
README.md
View File

@ -1,38 +1,105 @@
Bonemeal mod [bonemeal]
# Bonemeal
**Name**: `bonemeal`
This mod adds four new items into the game, bones which can be dug from normal
dirt which can be made into bonemeal, mulch which is is crafted using a tree and
8x leaves, and fertiliser which is a mixture of them both.
dirt which can be made into bonemeal, mulch which is is crafted using a tree
and 8x leaves, and fertiliser which is a mixture of them both.
Each item can be used on saplings and crops for a chance to grow them quicker as
well as dirt which will generate random grass, flowers or whichever decoration
is registered.
Each item can be used on saplings and crops for a chance to grow them quicker
as well as dirt which will generate random grass, flowers or whichever
decoration is registered.
Mulch has a strength of 1, Bonemeal 2 and Fertiliser 3 which means the stronger
Mulch has a strength of 1, Bonemeal 2 and Fertiliser 3. This means the stronger
the item, the more chance of growing saplings in low light, making crops sprout
quicker or simply decorate a larger area with grass and flowers.
The api.txt document shows how to add your own saplings, crops and grasses to
the list by using one of the 3 commands included and the mod.lua file gives you
many examples by using some of the popular mods available.
The [`api.txt`](https://notabug.org/TenPlus1/bonemeal/src/master/api.txt)
document shows how to add your own saplings, crops and grasses to the list by
using one of the 3 commands included and the mod.lua file gives you many
examples by using some of the popular mods available.
https://forum.minetest.net/viewtopic.php?f=9&t=16446
Changelog:
**Lucky Blocks**: 6
- 0.1 - Initial release
- 0.2 - Added global on_use function for bonemeal growth
- 0.3 - Added strength to on_use global for new items (mulch and fertiliser)
- 0.4 - Added Intllib support and fr.txt file
- 0.5 - Added support for default bush and acacia bush saplings
- 0.6 - Using newer functions, Minetest 0.4.16 and above needed to run
- 0.7 - Can be used on papyrus and cactus now, added coral recipe, api addition
- 0.8 - Added support for farming redo's new garlic, pepper and onion crops
- 0.9 - Added support for farming redo's pea and beetroot crops, checks for place_param
- 1.0 - add_deco() now adds to existing item list while set_deco() replaces item list (thanks h-v-smacker)
- 1.1 - Added {can_bonemeal=1} group for special nodes
- 1.2 - Added support for minetest 5.0 cactus seedling, blueberry bush sapling and emergent jungle tree saplings, additional flowers and pine bush sapling.
- 1.3 - Ability to craft dye from mulch, bonemeal and fertiliser (thanks orbea)
- 1.4 - Add support for fern saplings from plantlife mod (thanks nixnoxus)
## Changelog
Lucky Blocks: 6
### Version 0.1
* Initial release
### Version 0.2
* Added global `on_use` function for bonemeal growth
### Version 0.3
* Added strength to `on_use` global for new items (mulch and fertiliser)
### Version 0.4
* Added `Intllib` support and `fr.txt` file for French translation.
### Version 0.5
* Added support for default bush and acacia bush saplings
### Version 0.6
* Using newer functions. This means Minetest 0.4.16 and above needed to run
### Version 0.7
* Can be used on papyrus and cactus now
* Added coral recipe
* API addition
### Version 0.8
* Added support for farming redo's new garlic
* Added pepper and onion crops
### Version 0.9
* Added support for farming redo's pea and beetroot crops
* Checks for `place_param`
### Version 1.0
* `add_deco()` now adds to existing item list while `set_deco()` replaces item
list (thanks `h-v-smacker`)
### Version 1.1
* Added `{can_bonemeal=1}` group for special nodes
### Version 1.2
* Added support for Minetest 5.0 cactus seedling, blueberry bush sapling and
emergent jungle tree saplings, additional flowers and pine bush sapling
### Version 1.3
* Added ability to craft dye from mulch, bonemeal and fertiliser (thanks
`orbea`)
### Version 1.4
* Added support for fern saplings from `plantlife` mod (thanks `nixnoxus`)
### Version 1.5
* Added support for farming redo's asparagus, eggplant, spinach
### Version 1.6
* Added helper function for position and protection check
* Added ginger support
* Added moretrees poplar sapling
### Version 1.7
* Added farming redo's barley, hemp, rye, oat, mint, sunflower, rice seeds
* Added Everness saplings
* Update readme

View File

@ -1,5 +1,4 @@
default
intllib?
farming?
ethereal?
moretrees?
@ -12,3 +11,4 @@ dryplants?
df_trees?
df_farming?
df_primordial_items?
everness?

133
init.lua
View File

@ -5,9 +5,11 @@ local path = minetest.get_modpath("bonemeal")
local min, max, random = math.min, math.max, math.random
-- Load support for intllib.
local S = minetest.get_translator and minetest.get_translator("bonemeal") or
dofile(path .. "/intllib.lua")
-- translation support
local S = function(s) return s end -- default boilerplate function
if minetest.get_translator ~= nil then
S = minetest.get_translator("bonemeal") -- 5.x translation function
end
-- creative check
@ -129,7 +131,8 @@ local function particle_effect(pos)
maxexptime = 1,
minsize = 1,
maxsize = 3,
texture = "bonemeal_particle.png"
texture = "bonemeal_particle.png",
glow = 5
})
end
@ -138,15 +141,18 @@ end
local function grow_tree(pos, object)
if type(object) == "table" and object.axiom then
-- grow L-system tree
minetest.remove_node(pos)
minetest.spawn_tree(pos, object)
elseif type(object) == "string" and minetest.registered_nodes[object] then
-- place node
minetest.set_node(pos, {name = object})
elseif type(object) == "function" then
-- function
object(pos)
end
@ -288,15 +294,20 @@ local function check_soil(pos, nodename, strength)
for _, n in pairs(dirt) do
if random(5) == 5 then
if decor and #decor > 0 then
-- place random decoration (rare)
local dnum = #decor or 1
nod = decor[random(dnum)] or ""
end
else
if grass and #grass > 0 then
-- place random grass (common)
local dgra = #grass or 1
nod = #grass > 0 and grass[random(dgra)] or ""
end
end
@ -313,7 +324,9 @@ local function check_soil(pos, nodename, strength)
-- if param2 not preset then get from existing node
if not def then
local node = minetest.get_node_or_nil(pos2)
def = node and node.param2 or 0
end
@ -325,6 +338,39 @@ local function check_soil(pos, nodename, strength)
end
-- helper function
local function use_checks(user, pointed_thing)
-- make sure we use on node
if pointed_thing.type ~= "node" then
return false
end
-- get position and node info
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local def = minetest.registered_items[node.name]
local dirt = def and def.groups
-- does node have groups set
if not dirt then
return false
end
-- if we're using on ground, move position up
if dirt.soil or dirt.sand or dirt.can_bonemeal then
pos = pointed_thing.above
end
-- check if protected
if minetest.is_protected(pos, user:get_player_name()) then
return false
end
return node
end
-- global functions
@ -425,9 +471,12 @@ function bonemeal:set_deco(list)
-- replace existing entry
if list[l][1] == deco[n][1] then
deco[n][2] = list[l][2]
deco[n][3] = list[l][3]
list[l] = false
break
end
end
@ -459,13 +508,17 @@ function bonemeal:on_use(pos, strength, node)
if node.name == "default:papyrus" then
default.grow_papyrus(pos, node)
particle_effect(pos)
return true
elseif node.name == "default:cactus" then
default.grow_cactus(pos, node)
particle_effect(pos)
return true
end
@ -473,7 +526,9 @@ function bonemeal:on_use(pos, strength, node)
if minetest.get_item_group(node.name, "soil") > 0
or minetest.get_item_group(node.name, "sand") > 0
or minetest.get_item_group(node.name, "can_bonemeal") > 0 then
check_soil(pos, node.name, strength)
return true
end
@ -509,21 +564,16 @@ minetest.register_craftitem("bonemeal:mulch", {
on_use = function(itemstack, user, pointed_thing)
-- did we point at a node?
if pointed_thing.type ~= "node" then
return
end
-- use helper function to do checks and return position and node
local node = use_checks(user, pointed_thing)
-- is area protected?
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
return
end
if node then
-- call global on_use function with strength of 1
if bonemeal:on_use(pointed_thing.under, 1) then
-- call global on_use function with strength of 1
local used = bonemeal:on_use(pointed_thing.under, 1, node)
-- take item if not in creative
if not bonemeal.is_creative(user:get_player_name()) then
if used and not bonemeal.is_creative(user:get_player_name()) then
itemstack:take_item()
end
end
@ -540,21 +590,16 @@ minetest.register_craftitem("bonemeal:bonemeal", {
on_use = function(itemstack, user, pointed_thing)
-- did we point at a node?
if pointed_thing.type ~= "node" then
return
end
-- use helper function to do checks and return position and node
local node = use_checks(user, pointed_thing)
-- is area protected?
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
return
end
if node then
-- call global on_use function with strength of 2
if bonemeal:on_use(pointed_thing.under, 2) then
-- call global on_use function with strength of 2
local used = bonemeal:on_use(pointed_thing.under, 2, node)
-- take item if not in creative
if not bonemeal.is_creative(user:get_player_name()) then
if used and not bonemeal.is_creative(user:get_player_name()) then
itemstack:take_item()
end
end
@ -571,21 +616,16 @@ minetest.register_craftitem("bonemeal:fertiliser", {
on_use = function(itemstack, user, pointed_thing)
-- did we point at a node?
if pointed_thing.type ~= "node" then
return
end
-- use helper function to do checks and return position and node
local node = use_checks(user, pointed_thing)
-- is area protected?
if minetest.is_protected(pointed_thing.under, user:get_player_name()) then
return
end
if node then
-- call global on_use function with strength of 3
if bonemeal:on_use(pointed_thing.under, 3) then
-- call global on_use function with strength of 3
local used = bonemeal:on_use(pointed_thing.under, 3, node)
-- take item if not in creative
if not bonemeal.is_creative(user:get_player_name()) then
if used and not bonemeal.is_creative(user:get_player_name()) then
itemstack:take_item()
end
end
@ -635,10 +675,13 @@ minetest.register_craft({
})
-- bonemeal (from player bones)
minetest.register_craft({
output = "bonemeal:bonemeal 4",
recipe = {{"bones:bones"}}
})
if minetest.settings:get_bool("bonemeal.disable_deathbones_recipe") ~= true then
minetest.register_craft({
output = "bonemeal:bonemeal 4",
recipe = {{"bones:bones"}}
})
end
-- bonemeal (from coral skeleton)
minetest.register_craft({
@ -693,7 +736,11 @@ end
-- add support for other mods
dofile(path .. "/mods.lua")
dofile(path .. "/lucky_block.lua")
-- lucky block support
if minetest.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua")
end
print ("[MOD] bonemeal loaded")
print ("[MOD] Bonemeal loaded")

View File

@ -1,45 +0,0 @@
-- Fallback functions for when `intllib` is not installed.
-- Code released under Unlicense <http://unlicense.org>.
-- Get the latest version of this file at:
-- https://raw.githubusercontent.com/minetest-mods/intllib/master/lib/intllib.lua
local function format(str, ...)
local args = { ... }
local function repl(escape, open, num, close)
if escape == "" then
local replacement = tostring(args[tonumber(num)])
if open == "" then
replacement = replacement..close
end
return replacement
else
return "@"..open..num..close
end
end
return (str:gsub("(@?)@(%(?)(%d+)(%)?)", repl))
end
local gettext, ngettext
if minetest.get_modpath("intllib") then
if intllib.make_gettext_pair then
-- New method using gettext.
gettext, ngettext = intllib.make_gettext_pair()
else
-- Old method using text files.
gettext = intllib.Getter()
end
end
-- Fill in missing functions.
gettext = gettext or function(msgid, ...)
return format(msgid, ...)
end
ngettext = ngettext or function(msgid, msgid_plural, n, ...)
return format(n==1 and msgid or msgid_plural, ...)
end
return gettext, ngettext

View File

@ -19,3 +19,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Textures by TenPlus1 (CC0)

View File

@ -1,7 +0,0 @@
# init.lua
Mulch = Mantillo
Bone Meal = Comida de hueso
Fertiliser = Fertilizante
Bone = Hueso
[MOD] bonemeal loaded = [MOD] bonemeal cargado

View File

@ -1,7 +0,0 @@
# init.lua
Mulch = Paillis
Bone Meal = Poudre d'os
Fertiliser = Engrais
Bone = Os
[MOD] bonemeal loaded = [MOD] bonemeal chargé

View File

@ -1,7 +0,0 @@
# init.lua
Mulch = Pacciame
Bone Meal = Pasto osseo
Fertiliser = Fertilizzante
Bone = Ossa
[MOD] bonemeal loaded = [MOD] bonemeal caricata

View File

@ -1,7 +0,0 @@
# init.lua
Mulch = Мульча
Bone Meal = Костная Мука
Fertiliser = Удобрение
Bone = Кость
[MOD] bonemeal loaded = [MOD] костная мука загружена

View File

@ -1,7 +0,0 @@
# init.lua
Mulch =
Bone Meal =
Fertiliser =
Bone =
[MOD] bonemeal loaded =

View File

@ -11,18 +11,15 @@ local function growy(pos, player)
end
if minetest.get_modpath("lucky_block") then
lucky_block:add_blocks({
{"lig"},
{"dro", {"bonemeal:mulch"}, 10},
{"dro", {"bonemeal:bonemeal"}, 10},
{"dro", {"bonemeal:fertiliser"}, 10},
{"cus", growy},
{"nod", "default:chest", 0, {
{name = "bonemeal:mulch", max = 20},
{name = "bonemeal:bonemeal", max = 15},
{name = "bonemeal:fertiliser", max = 10}
}}
})
end
lucky_block:add_blocks({
{"lig"},
{"dro", {"bonemeal:mulch"}, 10},
{"dro", {"bonemeal:bonemeal"}, 10},
{"dro", {"bonemeal:fertiliser"}, 10},
{"cus", growy},
{"nod", "default:chest", 0, {
{name = "bonemeal:mulch", max = 20},
{name = "bonemeal:bonemeal", max = 15},
{name = "bonemeal:fertiliser", max = 10}
}}
})

View File

@ -1,4 +1,4 @@
name = bonemeal
depends = default
optional_depends = intllib, lucky_block, farming, ethereal, moretrees, technic_worldgen, flowers, dye, ferns, dryplants, df_trees, df_farming, df_primordial_items
optional_depends = lucky_block, farming, ethereal, moretrees, technic_worldgen, flowers, dye, ferns, dryplants, df_trees, df_farming, df_primordial_items, everness
description = Adds bone and bonemeal giving the ability to quickly grow plants and saplings.

View File

@ -25,9 +25,9 @@ if farming and farming.mod and farming.mod == "redo" then
{"farming:cucumber_", 4},
{"farming:potato_", 4},
{"farming:grapes_", 8},
{"farming:rhubarb_", 3},
{"farming:barley_", 7},
{"farming:hemp_", 8},
{"farming:rhubarb_", 4},
{"farming:barley_", 8, "farming:seed_barley"},
{"farming:hemp_", 8, "farming:seed_hemp"},
{"farming:chili_", 8},
{"farming:garlic_", 5},
{"farming:onion_", 5},
@ -35,10 +35,10 @@ if farming and farming.mod and farming.mod == "redo" then
{"farming:pineapple_", 8},
{"farming:pea_", 5},
{"farming:beetroot_", 5},
{"farming:rye_", 8},
{"farming:oat_", 8},
{"farming:rice_", 8},
{"farming:mint_", 4},
{"farming:rye_", 8, "farming:seed_rye"},
{"farming:oat_", 8, "farming:seed_oat"},
{"farming:rice_", 8, "farming:seed_rice"},
{"farming:mint_", 4, "farming:seed_mint"},
{"farming:cabbage_", 6},
{"farming:lettuce_", 5},
{"farming:blackberry_", 4},
@ -46,7 +46,12 @@ if farming and farming.mod and farming.mod == "redo" then
{"farming:soy_", 7},
{"farming:artichoke_", 5},
{"farming:parsley_", 3},
{"farming:sunflower_", 8}
{"farming:sunflower_", 8, "farming:seed_sunflower"},
{"farming:asparagus_", 5},
{"farming:eggplant_", 4},
{"farming:spinach_", 4},
{"farming:ginger_", 4},
{"ethereal:strawberry_", 8}
})
end
@ -122,6 +127,7 @@ if minetest.get_modpath("moretrees") then
{"moretrees:spruce_sapling", moretrees.grow_spruce, "soil"},
{"moretrees:cedar_sapling", moretrees.spawn_cedar_object, "soil"},
{"moretrees:poplar_sapling", moretrees.spawn_poplar_object, "soil"},
{"moretrees:poplar_small_sapling", moretrees.spawn_poplar_small_object, "soil"},
{"moretrees:willow_sapling", moretrees.spawn_willow_object, "soil"},
{"moretrees:rubber_tree_sapling", moretrees.spawn_rubber_tree_object, "soil"},
{"moretrees:fir_sapling", fir_grow, "soil"}
@ -177,8 +183,7 @@ end
if minetest.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
@ -240,14 +245,14 @@ 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)
df_primordial_items.get_primordial_mushroom(), (math.random(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)])
df_primordial_items.get_fern_schematic(), rotations[math.random(#rotations)])
end
local function blood_fix(pos)
@ -256,9 +261,9 @@ if minetest.get_modpath("df_primordial_items") then
bonemeal:add_sapling({
{"df_primordial_items:jungle_mushroom_sapling",
df_primordial_items.spawn_jungle_mushroom, "soil", true},
df_primordial_items.spawn_jungle_mushroom, "soil", true},
{"df_primordial_items:jungletree_sapling",
df_primordial_items.spawn_jungle_tree, "soil", true},
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}
@ -302,3 +307,22 @@ if minetest.get_modpath("df_primordial_items") then
{"df_primordial_items:dirt_with_mycelium", fgrass, fdeco}
})
end
if minetest.get_modpath("everness") then
bonemeal:add_sapling({
{"everness:baobab_sapling", Everness.grow_baobab_tree, "soil"},
{"everness:coral_tree_bioluminescent_sapling",
Everness.coral_tree_bioluminescent, "soil"},
{"everness:coral_tree_sapling", Everness.grow_coral_tree, "soil"},
{"everness:crystal_bush_sapling", Everness.grow_crystal_bush, "soil"},
{"everness:crystal_tree_large_sapling", Everness.grow_crystal_large_tree, "soil"},
{"everness:crystal_tree_sapling", Everness.grow_crystal_tree, "soil"},
{"everness:cursed_bush_sapling", Everness.grow_cursed_bush, "soil"},
{"everness:cursed_dream_tree_sapling", Everness.grow_cursed_dream_tree, "soil"},
{"everness:dry_tree_sapling", Everness.grow_dry_tree, "soil"},
{"everness:sequoia_tree_sapling", Everness.grow_sequoia_tree, "soil"},
{"everness:willow_tree_sapling", Everness.grow_willow_tree, "soil"}
})
end

BIN
screenshot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

2
settingtypes.txt Normal file
View File

@ -0,0 +1,2 @@
# Disable recipe for bones:bones to craft into bonemeal
bonemeal.disable_deathbones_recipe (Disable recipe for death bones into bonemeal) bool false