1
0
mirror of https://codeberg.org/tenplus1/bonemeal.git synced 2025-05-06 19:20:31 +02:00

change minetest. to core.

This commit is contained in:
tenplus1 2025-05-04 10:44:49 +01:00
parent 81f36673d3
commit d6893aae07
3 changed files with 82 additions and 82 deletions

View File

@ -1,7 +1,7 @@
-- MineClonia / VoxeLibre check
local mcl = minetest.get_modpath("mcl_core")
local mcl = core.get_modpath("mcl_core")
-- global
@ -17,16 +17,16 @@ bonemeal = {
-- translation support and vars
local S = minetest.get_translator("bonemeal")
local S = core.get_translator("bonemeal")
local a = bonemeal.item_list
local path = minetest.get_modpath("bonemeal")
local path = core.get_modpath("bonemeal")
local min, max, random = math.min, math.max, math.random
-- creative check helper
local creative_mode_cache = minetest.settings:get_bool("creative_mode")
local creative_mode_cache = core.settings:get_bool("creative_mode")
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
-- API tables
@ -39,7 +39,7 @@ local deco = {}
local function particle_effect(pos)
minetest.add_particlespawner({
core.add_particlespawner({
amount = 4,
time = 0.15,
minpos = pos,
@ -63,12 +63,12 @@ local function grow_tree(pos, object)
if type(object) == "table" and object.axiom then
minetest.remove_node(pos)
minetest.spawn_tree(pos, object) -- grow L-system tree
core.remove_node(pos)
core.spawn_tree(pos, object) -- grow L-system tree
elseif type(object) == "string" and minetest.registered_nodes[object] then
elseif type(object) == "string" and core.registered_nodes[object] then
minetest.set_node(pos, {name = object}) -- place node
core.set_node(pos, {name = object}) -- place node
elseif type(object) == "function" then
@ -81,7 +81,7 @@ end
local function check_sapling(pos, sapling_node, strength, light_ok)
-- what is sapling placed on?
local under = minetest.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
local under = core.get_node({x = pos.x, y = pos.y - 1, z = pos.z})
local can_grow, grow_on
@ -102,7 +102,7 @@ local function check_sapling(pos, sapling_node, strength, light_ok)
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
end
@ -157,7 +157,7 @@ local function check_crops(pos, nodename, strength, light_ok)
-- check for place_param setting
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
if not def or nod == nodename then
@ -166,11 +166,11 @@ local function check_crops(pos, nodename, strength, light_ok)
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)
minetest.get_node_timer(pos):start(10) -- restart any timers
core.get_node_timer(pos):start(10) -- restart any timers
return true
end
@ -186,7 +186,7 @@ local function check_soil(pos, nodename, strength)
local tall = max(strength - 2, 0)
-- 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}, {nodename})
@ -235,18 +235,18 @@ local function check_soil(pos, nodename, strength)
if nod and nod ~= "" then
-- get crop param2 value
def = minetest.registered_nodes[nod]
def = core.registered_nodes[nod]
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)
local node = core.get_node_or_nil(pos2)
def = node and node.param2 or 0
end
minetest.set_node(pos2, {name = nod, param2 = def})
core.set_node(pos2, {name = nod, param2 = def})
end
particle_effect(pos2)
@ -262,8 +262,8 @@ local function use_checks(user, pointed_thing)
-- get position and node info
local pos = pointed_thing.under
local node = minetest.get_node(pos)
local def = minetest.registered_items[node.name]
local node = core.get_node(pos)
local def = core.registered_items[node.name]
local dirt = def and def.groups
-- does node have groups set
@ -275,7 +275,7 @@ local function use_checks(user, pointed_thing)
end
-- 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
end
@ -399,7 +399,7 @@ end
function bonemeal:on_use(pos, strength, node)
-- get node pointed at
local node = node or minetest.get_node(pos)
local node = node or core.get_node(pos)
-- return if nothing there
if node.name == "ignore" then return end
@ -424,15 +424,15 @@ function bonemeal:on_use(pos, strength, node)
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) ; return true
end
-- grow grass and flowers
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
if core.get_item_group(node.name, "soil") > 0
or core.get_item_group(node.name, "sand") > 0
or core.get_item_group(node.name, "can_bonemeal") > 0 then
check_soil(pos, node.name, strength)
@ -442,7 +442,7 @@ function bonemeal:on_use(pos, strength, node)
-- 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 (core.get_node_light(pos) or 0) < (12 - (strength * 3)) then
light_ok = nil
end
@ -461,7 +461,7 @@ end
-- mulch (strength 1)
minetest.register_craftitem("bonemeal:mulch", {
core.register_craftitem("bonemeal:mulch", {
description = S("Mulch"),
inventory_image = "bonemeal_mulch.png",
@ -487,7 +487,7 @@ minetest.register_craftitem("bonemeal:mulch", {
-- bonemeal (strength 2)
minetest.register_craftitem("bonemeal:bonemeal", {
core.register_craftitem("bonemeal:bonemeal", {
description = S("Bone Meal"),
inventory_image = "bonemeal_item.png",
@ -513,7 +513,7 @@ minetest.register_craftitem("bonemeal:bonemeal", {
-- fertiliser (strength 3)
minetest.register_craftitem("bonemeal:fertiliser", {
core.register_craftitem("bonemeal:fertiliser", {
description = S("Fertiliser"),
inventory_image = "bonemeal_fertiliser.png",
@ -539,7 +539,7 @@ minetest.register_craftitem("bonemeal:fertiliser", {
-- bone
minetest.register_craftitem("bonemeal:bone", {
core.register_craftitem("bonemeal:bone", {
description = S("Bone"),
inventory_image = "bonemeal_bone.png",
groups = {bone = 1}
@ -547,7 +547,7 @@ minetest.register_craftitem("bonemeal:bone", {
-- gelatin powder
minetest.register_craftitem("bonemeal:gelatin_powder", {
core.register_craftitem("bonemeal:gelatin_powder", {
description = S("Gelatin Powder"),
inventory_image = "bonemeal_gelatin_powder.png",
groups = {food_gelatin = 1, flammable = 2}
@ -557,7 +557,7 @@ minetest.register_craftitem("bonemeal:gelatin_powder", {
-- gelatin powder
minetest.register_craft({
core.register_craft({
output = "bonemeal:gelatin_powder 4",
recipe = {
{"group:bone", "group:bone", "group:bone"},
@ -571,7 +571,7 @@ minetest.register_craft({
-- bonemeal (from bone)
minetest.register_craft({
core.register_craft({
type = "cooking",
output = "bonemeal:bonemeal 2",
recipe = "group:bone",
@ -580,9 +580,9 @@ minetest.register_craft({
-- bonemeal (from player bones)
if minetest.settings:get_bool("bonemeal.disable_deathbones_recipe") ~= true then
if core.settings:get_bool("bonemeal.disable_deathbones_recipe") ~= true then
minetest.register_craft({
core.register_craft({
output = "bonemeal:bone 2",
recipe = {{"bones:bones"}}
})
@ -590,14 +590,14 @@ end
-- bonemeal (from coral skeleton)
minetest.register_craft({
core.register_craft({
output = "bonemeal:bonemeal 2",
recipe = {{a.coral}}
})
-- mulch
minetest.register_craft({
core.register_craft({
output = "bonemeal:mulch 4",
recipe = {
{"group:tree", "group:leaves", "group:leaves"},
@ -606,7 +606,7 @@ minetest.register_craft({
}
})
minetest.register_craft({
core.register_craft({
output = "bonemeal:mulch",
recipe = {
{"group:seed", "group:seed", "group:seed"},
@ -617,16 +617,16 @@ minetest.register_craft({
-- fertiliser
minetest.register_craft({
core.register_craft({
output = "bonemeal:fertiliser 2",
recipe = {{"bonemeal:bonemeal", "bonemeal:mulch"}}
})
-- add bones to dirt
if minetest.registered_items[a.dirt] then
if core.registered_items[a.dirt] then
minetest.override_item(a.dirt, {
core.override_item(a.dirt, {
drop = {
max_items = 1,
items = {
@ -648,7 +648,7 @@ dofile(path .. "/mods.lua")
-- lucky block support
if minetest.get_modpath("lucky_block") then
if core.get_modpath("lucky_block") then
dofile(path .. "/lucky_block.lua")
end

View File

@ -3,7 +3,7 @@
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
bonemeal:on_use(dpos, 5)

View File

@ -1,9 +1,9 @@
-- craft bones from animalmaterials into bonemeal
if minetest.get_modpath("animalmaterials") then
if core.get_modpath("animalmaterials") then
minetest.register_craft({
core.register_craft({
output = "bonemeal:bonemeal 2",
recipe = {{"animalmaterials:bone"}}
})
@ -11,13 +11,13 @@ end
-- default additions
if minetest.get_modpath("default") then
if core.get_modpath("default") then
-- saplings
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.grow_new_snowy_pine_tree(pos)
@ -27,11 +27,11 @@ if minetest.get_modpath("default") then
end
local function cactus_grow(pos)
default.grow_cactus(pos, minetest.get_node(pos))
default.grow_cactus(pos, core.get_node(pos))
end
local function papyrus_grow(pos)
default.grow_papyrus(pos, minetest.get_node(pos))
default.grow_papyrus(pos, core.get_node(pos))
end
bonemeal:add_sapling({
@ -65,9 +65,9 @@ if minetest.get_modpath("default") then
local flowers = {}
-- add flowers from other mods
minetest.after(0.1, function()
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
and def.groups.flower
@ -155,7 +155,7 @@ end
-- ethereal crops, saplings and grass
if minetest.get_modpath("ethereal") then
if core.get_modpath("ethereal") then
bonemeal:add_crop({
{"ethereal:strawberry_", 8},
@ -203,12 +203,12 @@ end
-- moretrees saplings
if minetest.get_modpath("moretrees") then
if core.get_modpath("moretrees") then
-- special fir check for snow
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
moretrees.grow_fir_snow(pos)
@ -239,7 +239,7 @@ end
-- technic rubber tree
if minetest.get_modpath("technic_worldgen") then
if core.get_modpath("technic_worldgen") then
bonemeal:add_sapling({
{"moretrees:rubber_tree_sapling", technic.rubber_tree_model, "soil"}
@ -248,14 +248,14 @@ 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)
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)
end
@ -266,7 +266,7 @@ end
-- ferns
if minetest.get_modpath("ferns") then
if core.get_modpath("ferns") then
local function y_func(grow_func)
return function(pos)
@ -286,7 +286,7 @@ end
-- dryplants sapling
if minetest.get_modpath("dryplants") then
if core.get_modpath("dryplants") then
bonemeal:add_sapling({
{"dryplants:reedmace_sapling", y_func(abstract_dryplants.grow_reedmace), "soil"}
@ -295,13 +295,13 @@ 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"}
for mat, dye in pairs(bonemeal_dyes) do
minetest.register_craft({
core.register_craft({
output = "dye:" .. dye .. " 4",
recipe = {
{"bonemeal:" .. mat}
@ -312,34 +312,34 @@ end
-- df_trees saplings
if minetest.get_modpath("df_trees") then
if core.get_modpath("df_trees") then
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
local function fungiwood_fix(pos)
minetest.remove_node(pos) ; df_trees.spawn_fungiwood(pos)
core.remove_node(pos) ; df_trees.spawn_fungiwood(pos)
end
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
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
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
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
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
bonemeal:add_sapling({
@ -356,7 +356,7 @@ end
-- df_farming crops
if minetest.get_modpath("df_farming") then
if core.get_modpath("df_farming") then
bonemeal:add_crop({
{"df_farming:cave_wheat_", 8, "df_farming:cave_wheat_seed", true},
@ -370,23 +370,23 @@ 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)
minetest.set_node(pos, {name = "air"})
core.set_node(pos, {name = "air"})
mapgen_helper.place_schematic(pos,
df_primordial_items.get_primordial_mushroom(), (math.random(4) - 1) * 90)
end
local function fern_fix(pos)
minetest.set_node(pos, {name = "air"})
core.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(#rotations)])
end
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
bonemeal:add_sapling({
@ -440,7 +440,7 @@ end
-- everness saplings
if minetest.get_modpath("everness") then
if core.get_modpath("everness") then
bonemeal:add_sapling({
{"everness:baobab_sapling", Everness.grow_baobab_tree, "soil"},
@ -460,16 +460,16 @@ end
-- bush classic fruit
if minetest.get_modpath("bushes_classic") then
if core.get_modpath("bushes_classic") then
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")
-- only change if meta found
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