Merge remote-tracking branch 'upstream/master' into nalc-1.2-dev

This commit is contained in:
Sys Quatre 2020-06-16 21:21:14 +02:00
commit 7053e44ea4
9 changed files with 110 additions and 69 deletions

View File

@ -32,5 +32,6 @@ Changelog:
- 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)
Lucky Blocks: 6

View File

@ -6,3 +6,4 @@ moretrees?
technic_worldgen?
lucky_block?
flowers?
dye?

138
init.lua
View File

@ -1,9 +1,12 @@
bonemeal = {}
local path = minetest.get_modpath("bonemeal")
local min, max, random = math.min, math.max, math.random
-- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname())
local S, NS = dofile(MP .. "/intllib.lua")
local S, NS = dofile(path .. "/intllib.lua")
-- creative check
@ -16,7 +19,7 @@ end
-- default crops
local crops = {
{"farming:cotton_", 8, "farming:seed_cotton"},
{"farming:wheat_", 8, "farming:seed_wheat"},
{"farming:wheat_", 8, "farming:seed_wheat"}
}
@ -45,7 +48,7 @@ local saplings = {
{"default:acacia_bush_sapling", default.grow_acacia_bush, "soil"},
{"default:large_cactus_seedling", default.grow_large_cactus, "sand"},
{"default:blueberry_bush_sapling", default.grow_blueberry_bush, "soil"},
{"default:pine_bush_sapling", default.grow_pine_bush, "soil"},
{"default:pine_bush_sapling", default.grow_pine_bush, "soil"}
}
-- helper tables ( "" denotes a blank item )
@ -59,15 +62,14 @@ local dry_grass = {
"default:dry_grass_5", "", ""
}
local flowers = {
"flowers:dandelion_white", "flowers:dandelion_yellow", "flowers:geranium",
"flowers:rose", "flowers:tulip", "flowers:viola", ""
}
-- add all in-game flowers except waterlily
local flowers = {}
-- 5.0 flower check
if minetest.registered_nodes["flowers:tulip_black"] then
flowers[#flowers + 1] = "flowers:tulip_black"
flowers[#flowers + 1] = "flowers:chrysanthemum_green"
for node, def in pairs(minetest.registered_nodes) do
if def.groups.flower and not node:find("waterlily") then
flowers[#flowers + 1] = node
end
end
-- add additional bakedclay flowers if enabled
@ -88,7 +90,9 @@ local deco = {
}
----- local functions
--
-- local functions
--
-- particles
@ -107,7 +111,7 @@ local function particle_effect(pos)
maxexptime = 1,
minsize = 1,
maxsize = 3,
texture = "bonemeal_particle.png",
texture = "bonemeal_particle.png"
})
end
@ -191,7 +195,7 @@ local function check_crops(pos, nodename, strength)
-- grow registered crops
for n = 1, #crops do
if string.find(nodename, crops[n][1])
if nodename:find(crops[n][1])
or nodename == crops[n][3] then
-- separate mod and node name
@ -200,7 +204,7 @@ local function check_crops(pos, nodename, strength)
-- get stage number or set to 0 for seed
stage = tonumber( crop:split("_")[2] ) or 0
stage = math.min(stage + strength, crops[n][2])
stage = min(stage + strength, crops[n][2])
-- check for place_param setting
nod = crops[n][1] .. stage
@ -222,7 +226,7 @@ local function check_soil(pos, nodename, strength)
-- set radius according to strength
local side = strength - 1
local tall = math.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 {}
@ -258,29 +262,38 @@ local function check_soil(pos, nodename, strength)
local pos2, nod, def
-- loop through soil
for _,n in pairs(dirt) do
for _, n in pairs(dirt) do
pos2 = n
pos2.y = pos2.y + 1
if math.random(1, 5) == 5 then
if random(5) == 5 then
if decor and #decor > 0 then
-- place random decoration (rare)
local dnum = #decor or 1
nod = decor[math.random(1, dnum)] or ""
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[math.random(1, dgra)] or ""
nod = #grass > 0 and grass[random(dgra)] or ""
end
end
pos2 = n
pos2.y = pos2.y + 1
if nod and nod ~= "" then
-- get crop param2 value
def = minetest.registered_nodes[nod]
def = def and def.place_param2 or 0
def = def and def.place_param2
-- 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
minetest.set_node(pos2, {name = nod, param2 = def})
end
@ -299,7 +312,7 @@ end
function bonemeal:add_sapling(list)
for n = 1, #list do
table.insert(saplings, list[n])
saplings[#saplings + 1] = list[n]
end
end
@ -310,7 +323,7 @@ end
function bonemeal:add_crop(list)
for n = 1, #list do
table.insert(crops, list[n])
crops[#crops + 1] = list[n]
end
end
@ -330,11 +343,11 @@ function bonemeal:add_deco(list)
if list[l][1] == deco[n][1] then
-- adding grass types
for _,extra in ipairs(list[l][2]) do
for _, extra in pairs(list[l][2]) do
if extra ~= "" then
for __,entry in ipairs(deco[n][2]) do
for _, entry in pairs(deco[n][2]) do
if extra == entry then
extra = false
@ -344,16 +357,16 @@ function bonemeal:add_deco(list)
end
if extra then
table.insert(deco[n][2], extra)
deco[n][2][#deco[n][2] + 1] = extra
end
end
-- adding decoration types
for _,extra in ipairs(list[l][3]) do
for _, extra in ipairs(list[l][3]) do
if extra ~= "" then
for __,entry in ipairs(deco[n][3]) do
for __, entry in pairs(deco[n][3]) do
if extra == entry then
extra = false
@ -363,7 +376,7 @@ function bonemeal:add_deco(list)
end
if extra then
table.insert(deco[n][3], extra)
deco[n][3][#deco[n][3] + 1] = extra
end
end
@ -373,7 +386,7 @@ function bonemeal:add_deco(list)
end
if list[l] then
table.insert(deco, list[l])
deco[#deco + 1] = list[l]
end
end
end
@ -397,7 +410,7 @@ function bonemeal:set_deco(list)
end
if list[l] then
table.insert(deco, list[l])
deco[#deco + 1] = list[l]
end
end
end
@ -416,8 +429,8 @@ function bonemeal:on_use(pos, strength, node)
-- make sure strength is between 1 and 4
strength = strength or 1
strength = math.max(strength, 1)
strength = math.min(strength, 4)
strength = max(strength, 1)
strength = min(strength, 4)
-- papyrus and cactus
if node.name == "default:papyrus" then
@ -447,8 +460,8 @@ function bonemeal:on_use(pos, strength, node)
end
-- check for tree growth if pointing at sapling
-- if minetest.get_item_group(node.name, "sapling") > 0
if math.random(1, (5 - strength)) == 1 then
if minetest.get_item_group(node.name, "sapling") > 0
and random(5 - strength) == 1 then
check_sapling(pos, node.name)
return
end
@ -458,7 +471,9 @@ function bonemeal:on_use(pos, strength, node)
end
----- items
--
-- items
--
-- mulch (strength 1)
@ -487,7 +502,7 @@ minetest.register_craftitem("bonemeal:mulch", {
bonemeal:on_use(pointed_thing.under, 1)
return itemstack
end,
end
})
@ -517,7 +532,7 @@ minetest.register_craftitem("bonemeal:bonemeal", {
bonemeal:on_use(pointed_thing.under, 2)
return itemstack
end,
end
})
@ -547,7 +562,7 @@ minetest.register_craftitem("bonemeal:fertiliser", {
bonemeal:on_use(pointed_thing.under, 3)
return itemstack
end,
end
})
@ -555,50 +570,54 @@ minetest.register_craftitem("bonemeal:fertiliser", {
minetest.register_craftitem("bonemeal:bone", {
description = S("Bone"),
inventory_image = "bonemeal_bone.png",
groups = {bone = 1}
})
-- gelatin powder
minetest.register_craftitem("bonemeal:gelatin_powder", {
description = S("Gelatin Powder"),
inventory_image = "bonemeal_gelatin_powder.png",
groups = {food_gelatin = 1, flammable = 2},
groups = {food_gelatin = 1, flammable = 2}
})
--- crafting recipes
--
-- crafting recipes
--
-- gelatin powder
minetest.register_craft({
output = "bonemeal:gelatin_powder 4",
recipe = {
{"bonemeal:bone", "bonemeal:bone", "bonemeal:bone"},
{"group:bone", "group:bone", "group:bone"},
{"bucket:bucket_water", "bucket:bucket_water", "bucket:bucket_water"},
{"bucket:bucket_water", "default:torch", "bucket:bucket_water"},
},
replacements = {
{"bucket:bucket_water", "bucket:bucket_empty 5"},
},
}
})
-- bonemeal (from bone)
minetest.register_craft({
type = "shapeless",
output = "bonemeal:bonemeal 2",
recipe = {"bonemeal:bone"},
recipe = {"group:bone"}
})
-- bonemeal (from player bones)
minetest.register_craft({
type = "shapeless",
output = "bonemeal:bonemeal 4",
recipe = {"bones:bones"},
recipe = {"bones:bones"}
})
-- bonemeal (from coral skeleton)
minetest.register_craft({
type = "shapeless",
output = "bonemeal:bonemeal 2",
recipe = {"default:coral_skeleton"},
recipe = {"default:coral_skeleton"}
})
-- mulch
@ -609,14 +628,14 @@ minetest.register_craft({
"group:tree", "group:leaves", "group:leaves",
"group:leaves", "group:leaves", "group:leaves",
"group:leaves", "group:leaves", "group:leaves"
},
}
})
-- fertiliser
minetest.register_craft({
type = "shapeless",
output = "bonemeal:fertiliser 2",
recipe = {"bonemeal:bonemeal", "bonemeal:mulch"},
recipe = {"bonemeal:bonemeal", "bonemeal:mulch"}
})
@ -630,21 +649,16 @@ else
items = {
{
items = {"bonemeal:bone"},
rarity = 30,
rarity = 40
},
{
items = {"default:dirt"},
},
},
items = {"default:dirt"}
}
}
}
end
minetest.override_item("default:dirt", {
drop = drop,
})
-- add support for other mods
local path = minetest.get_modpath("bonemeal")
dofile(path .. "/mods.lua")
dofile(path .. "/lucky_block.lua")

7
locale/ru.txt Normal file
View File

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

View File

@ -5,7 +5,7 @@ if minetest.get_modpath("animalmaterials") then
minetest.register_craft({
type = "shapeless",
output = "bonemeal:bonemeal 2",
recipe = {"animalmaterials:bone"},
recipe = {"animalmaterials:bone"}
})
end
@ -39,6 +39,7 @@ if farming and farming.mod and farming.mod == "redo" then
{"farming:rye_", 8},
{"farming:oat_", 8},
{"farming:rice_", 8},
{"farming:mint_", 4}
})
end
@ -47,7 +48,7 @@ if minetest.get_modpath("ethereal") then
bonemeal:add_crop({
{"ethereal:strawberry_", 8},
{"ethereal:onion_", 5},
{"ethereal:onion_", 5}
})
bonemeal:add_sapling({
@ -63,7 +64,7 @@ if minetest.get_modpath("ethereal") then
{"ethereal:orange_tree_sapling", ethereal.grow_orange_tree, "soil"},
{"ethereal:bamboo_sprout", ethereal.grow_bamboo_tree, "soil"},
{"ethereal:birch_sapling", ethereal.grow_birch_tree, "soil"},
{"ethereal:sakura_sapling", ethereal.grow_sakura_tree, "soil"},
{"ethereal:sakura_sapling", ethereal.grow_sakura_tree, "soil"}
})
local grass = {"default:grass_3", "default:grass_4", "default:grass_5", ""}
@ -79,7 +80,7 @@ if minetest.get_modpath("ethereal") then
{"ethereal:mushroom_dirt", {}, {"flowers:mushroom_red", "flowers:mushroom_brown", "", "", ""}},
{"ethereal:jungle_dirt", grass, {"default:junglegrass", "", "", ""}},
{"ethereal:grove_dirt", grass, {"ethereal:fern", "", "", ""}},
{"ethereal:bamboo_dirt", grass, {}},
{"ethereal:bamboo_dirt", grass, {}}
})
end
@ -115,13 +116,13 @@ if minetest.get_modpath("moretrees") then
{"moretrees:poplar_sapling", moretrees.spawn_poplar_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"},
{"moretrees:fir_sapling", fir_grow, "soil"}
})
elseif minetest.get_modpath("technic_worldgen") then
bonemeal:add_sapling({
{"moretrees:rubber_tree_sapling", technic.rubber_tree_model, "soil"},
{"moretrees:rubber_tree_sapling", technic.rubber_tree_model, "soil"}
})
end
@ -138,6 +139,23 @@ if minetest.get_modpath("caverealms") then
end
bonemeal:add_sapling({
{"caverealms:mushroom_sapling", add_shroom, "soil"},
{"caverealms:mushroom_sapling", add_shroom, "soil"}
})
end
if minetest.get_modpath("dye") then
local bonemeal_dyes = {
bonemeal = "white", fertiliser = "green", mulch = "brown"}
for mat, dye in pairs(bonemeal_dyes) do
minetest.register_craft({
output = "dye:" .. dye .. " 4",
recipe = {
{"bonemeal:" .. mat}
},
})
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 182 B