From cdac09a8f4f035a56aa23536641a037ae8cc7301 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Sun, 11 Aug 2024 08:47:26 +0100 Subject: [PATCH] properly detect and use sounds from default/mcl --- api.txt | 21 +++++++++++++++++++++ compatibility.lua | 6 +++--- crops/artichoke.lua | 2 +- crops/asparagus.lua | 2 +- crops/barley.lua | 2 +- crops/beans.lua | 6 +++--- crops/beetroot.lua | 2 +- crops/blackberry.lua | 2 +- crops/blueberry.lua | 2 +- crops/cabbage.lua | 2 +- crops/carrot.lua | 2 +- crops/chili.lua | 2 +- crops/cocoa.lua | 4 ++-- crops/coffee.lua | 4 ++-- crops/corn.lua | 4 ++-- crops/cotton.lua | 4 ++-- crops/cucumber.lua | 2 +- crops/eggplant.lua | 2 +- crops/garlic.lua | 4 ++-- crops/ginger.lua | 2 +- crops/grapes.lua | 6 +++--- crops/hemp.lua | 12 ++++++------ crops/lettuce.lua | 2 +- crops/melon.lua | 4 ++-- crops/mint.lua | 2 +- crops/onion.lua | 2 +- crops/parsley.lua | 2 +- crops/peas.lua | 2 +- crops/pepper.lua | 4 ++-- crops/pineapple.lua | 2 +- crops/potato.lua | 2 +- crops/pumpkin.lua | 8 ++++---- crops/raspberry.lua | 2 +- crops/rhubarb.lua | 2 +- crops/rice.lua | 2 +- crops/soy.lua | 6 +++--- crops/spinach.lua | 2 +- crops/strawberry.lua | 2 +- crops/sunflower.lua | 4 ++-- crops/tomato.lua | 2 +- crops/vanilla.lua | 4 ++-- crops/wheat.lua | 8 ++++---- food.lua | 10 +++++----- init.lua | 41 ++++++++++++++++++++++++----------------- 44 files changed, 119 insertions(+), 91 deletions(-) diff --git a/api.txt b/api.txt index eb25cb9..19481f4 100644 --- a/api.txt +++ b/api.txt @@ -70,3 +70,24 @@ A handy function that starts a crops timer with a randomly selected time set by stage_length setting. This is mostly used for special functions or 3rd party mods. farming.start_seed_timer(pos) + + +Node Sounds +----------- + +Farming Redo will detect wether the Default mod or MineClone/VoxeLibre mod is active and +store whichever sound set is available inside the following to save any other farming +mods from having to detect it themselves: + +farming.node_sound_defaults() +farming.node_sound_stone_defaults() +farming.node_sound_dirt_defaults() +farming.node_sound_sand_defaults() +farming.node_sound_gravel_defaults() +farming.node_sound_wood_defaults() +farming.node_sound_leaves_defaults() +farming.node_sound_ice_defaults() +farming.node_sound_metal_defaults() +farming.node_sound_water_defaults() +farming.node_sound_snow_defaults() +farming.node_sound_glass_defaults() diff --git a/compatibility.lua b/compatibility.lua index a476621..5ecb4b5 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -41,7 +41,7 @@ else }, is_ground_content = false, on_use = minetest.item_eat(2), - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() }) farming.add_eatable("ethereal:banana", 2) @@ -55,7 +55,7 @@ else waving = 1, groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2}, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() }) alias("farming_plus:banana_sapling", "default:sapling") @@ -105,7 +105,7 @@ else }, is_ground_content = false, on_use = minetest.item_eat(4), - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() }) farming.add_eatable("ethereal:orange", 4) diff --git a/crops/artichoke.lua b/crops/artichoke.lua index 4528ae8..54f0fa2 100644 --- a/crops/artichoke.lua +++ b/crops/artichoke.lua @@ -33,7 +33,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/asparagus.lua b/crops/asparagus.lua index fed92f1..f72ed9c 100644 --- a/crops/asparagus.lua +++ b/crops/asparagus.lua @@ -35,7 +35,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/barley.lua b/crops/barley.lua index ec189e9..b091049 100644 --- a/crops/barley.lua +++ b/crops/barley.lua @@ -65,7 +65,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/beans.lua b/crops/beans.lua index 82bcc43..7dafc6b 100644 --- a/crops/beans.lua +++ b/crops/beans.lua @@ -102,7 +102,7 @@ minetest.register_node("farming:beanpole", { selection_box = farming.select, groups = {handy = 1, snappy = 3, flammable = 2, attached_node = 1}, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), on_place = function(itemstack, placer, pointed_thing) @@ -195,7 +195,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 @@ -259,7 +259,7 @@ minetest.register_node("farming:beanbush", { compostability = 35, not_in_creative_inventory = 1 }, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() }) -- mapgen diff --git a/crops/beetroot.lua b/crops/beetroot.lua index d3e88fd..b770eb2 100644 --- a/crops/beetroot.lua +++ b/crops/beetroot.lua @@ -56,7 +56,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/blackberry.lua b/crops/blackberry.lua index 6c8f7f0..6edbb78 100644 --- a/crops/blackberry.lua +++ b/crops/blackberry.lua @@ -32,7 +32,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/blueberry.lua b/crops/blueberry.lua index 9c1ed7c..b222a56 100644 --- a/crops/blueberry.lua +++ b/crops/blueberry.lua @@ -76,7 +76,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/cabbage.lua b/crops/cabbage.lua index d1a0731..3a09e5b 100644 --- a/crops/cabbage.lua +++ b/crops/cabbage.lua @@ -32,7 +32,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/carrot.lua b/crops/carrot.lua index 6393501..5a8556d 100644 --- a/crops/carrot.lua +++ b/crops/carrot.lua @@ -75,7 +75,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } diff --git a/crops/chili.lua b/crops/chili.lua index a71d8ab..fbca3ea 100644 --- a/crops/chili.lua +++ b/crops/chili.lua @@ -75,7 +75,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/cocoa.lua b/crops/cocoa.lua index 9d99058..9fabda0 100644 --- a/crops/cocoa.lua +++ b/crops/cocoa.lua @@ -130,7 +130,7 @@ minetest.register_node("farming:chocolate_block", { tiles = {"farming_chocolate_block.png"}, is_ground_content = false, groups = {cracky = 2, oddly_breakable_by_hand = 2}, - sounds = farming.sounds.node_sound_stone_defaults() + sounds = farming.node_sound_stone_defaults() }) minetest.register_craft({ @@ -164,7 +164,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), -- custom function to check for growing conditions, returning True when found growth_check = function(pos, node_name) diff --git a/crops/coffee.lua b/crops/coffee.lua index 3230dc9..2522f38 100644 --- a/crops/coffee.lua +++ b/crops/coffee.lua @@ -28,7 +28,7 @@ minetest.register_node("farming:coffee_cup", { groups = {vessel = 1, dig_immediate = 3, attached_node = 1, drink = 1}, is_ground_content = false, on_use = minetest.item_eat(2, "vessels:drinking_glass"), - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) farming.add_eatable("farming:coffee_cup", 2) @@ -64,7 +64,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/corn.lua b/crops/corn.lua index 9bf600c..352b79f 100644 --- a/crops/corn.lua +++ b/crops/corn.lua @@ -94,7 +94,7 @@ minetest.register_node("farming:bottle_ethanol", { fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} }, groups = {vessel = 1, dig_immediate = 3, attached_node = 1}, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) minetest.register_craft( { @@ -130,7 +130,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/cotton.lua b/crops/cotton.lua index 9a83d3e..0b2dd5c 100644 --- a/crops/cotton.lua +++ b/crops/cotton.lua @@ -25,7 +25,7 @@ minetest.register_node("farming:cotton_wild", { {items = {"farming:seed_cotton"}, rarity = 1} } }, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-6 / 16, -8 / 16, -6 / 16, 6 / 16, 5 / 16, 6 / 16} @@ -124,7 +124,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/cucumber.lua b/crops/cucumber.lua index 3f96a4f..305fa07 100644 --- a/crops/cucumber.lua +++ b/crops/cucumber.lua @@ -36,7 +36,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/eggplant.lua b/crops/eggplant.lua index 9b8009a..a7b17ee 100644 --- a/crops/eggplant.lua +++ b/crops/eggplant.lua @@ -34,7 +34,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/garlic.lua b/crops/garlic.lua index ea9c054..3d4c635 100644 --- a/crops/garlic.lua +++ b/crops/garlic.lua @@ -54,7 +54,7 @@ minetest.register_node("farming:garlic_braid", { }, groups = {vessel = 1, dig_immediate = 3, flammable = 3, compostability = 65}, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), node_box = { type = "fixed", fixed = { @@ -97,7 +97,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/ginger.lua b/crops/ginger.lua index 9a88ecd..1c47ca4 100644 --- a/crops/ginger.lua +++ b/crops/ginger.lua @@ -33,7 +33,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/grapes.lua b/crops/grapes.lua index eb75eef..98805ba 100644 --- a/crops/grapes.lua +++ b/crops/grapes.lua @@ -99,7 +99,7 @@ minetest.register_node("farming:trellis", { selection_box = farming.select, groups = {handy = 1, snappy = 3, flammable = 2, attached_node = 1}, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), on_place = function(itemstack, placer, pointed_thing) @@ -192,7 +192,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 @@ -268,7 +268,7 @@ minetest.register_node("farming:grapebush", { not_in_creative_inventory = 1, compostability = 35 }, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() }) -- mapgen diff --git a/crops/hemp.lua b/crops/hemp.lua index 6b6bbcf..0fc8382 100644 --- a/crops/hemp.lua +++ b/crops/hemp.lua @@ -54,7 +54,7 @@ minetest.register_node("farming:hemp_oil", { food_oil = 1, vessel = 1, dig_immediate = 3, attached_node = 1, compostability = 45 }, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) minetest.register_craft( { @@ -121,7 +121,7 @@ minetest.register_node("farming:hemp_block", { compostability = 85 }, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), _mcl_hardness = 0.8, _mcl_blast_resistance = 1 }) @@ -144,7 +144,7 @@ if minetest.global_exists("stairs") then {snappy = 2, oddly_breakable_by_hand = 1, flammable = 2}, {"farming_hemp_block.png"}, "Hemp Block", - farming.sounds.node_sound_leaves_defaults()) + farming.node_sound_leaves_defaults()) else stairs.register_stair_and_slab("hemp_block", "farming:hemp_block", @@ -152,7 +152,7 @@ if minetest.global_exists("stairs") then {"farming_hemp_block.png"}, "Hemp Block Stair", "Hemp Block Slab", - farming.sounds.node_sound_leaves_defaults()) + farming.node_sound_leaves_defaults()) end end @@ -190,7 +190,7 @@ minetest.register_node("farming:hemp_rope", { oddly_breakable_by_hand = 3, compostability = 55 }, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), selection_box = { type = "fixed", fixed = {-1/7, -1/2, -1/7, 1/7, 1/2, 1/7} @@ -226,7 +226,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/lettuce.lua b/crops/lettuce.lua index 2423525..a7363ed 100644 --- a/crops/lettuce.lua +++ b/crops/lettuce.lua @@ -31,7 +31,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/melon.lua b/crops/melon.lua index 000044c..14cd2a3 100644 --- a/crops/melon.lua +++ b/crops/melon.lua @@ -47,7 +47,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 @@ -91,7 +91,7 @@ minetest.register_node("farming:melon_8", { }, is_ground_content = false, drop = "farming:melon_8", - sounds = farming.sounds.node_sound_wood_defaults(), + sounds = farming.node_sound_wood_defaults(), paramtype2 = "facedir", on_place = minetest.rotate_node, _mcl_hardness = 0.8, diff --git a/crops/mint.lua b/crops/mint.lua index 809f7b6..e56323a 100644 --- a/crops/mint.lua +++ b/crops/mint.lua @@ -73,7 +73,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/onion.lua b/crops/onion.lua index 771ba1f..ecb6651 100644 --- a/crops/onion.lua +++ b/crops/onion.lua @@ -69,7 +69,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/parsley.lua b/crops/parsley.lua index 237985c..d120567 100644 --- a/crops/parsley.lua +++ b/crops/parsley.lua @@ -33,7 +33,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/peas.lua b/crops/peas.lua index 857860b..fe2cb36 100644 --- a/crops/peas.lua +++ b/crops/peas.lua @@ -59,7 +59,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/pepper.lua b/crops/pepper.lua index 2569485..76794e3 100644 --- a/crops/pepper.lua +++ b/crops/pepper.lua @@ -67,7 +67,7 @@ minetest.register_node("farming:pepper_ground", { dig_immediate = 3, attached_node = 1, compostability = 30 }, is_ground_content = false, - sounds = farming.sounds.node_sound_defaults(), + sounds = farming.node_sound_defaults(), selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} @@ -103,7 +103,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/pineapple.lua b/crops/pineapple.lua index 9b3a57e..bb3cb1a 100644 --- a/crops/pineapple.lua +++ b/crops/pineapple.lua @@ -102,7 +102,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/potato.lua b/crops/potato.lua index 63ce789..63f86bd 100644 --- a/crops/potato.lua +++ b/crops/potato.lua @@ -79,7 +79,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/pumpkin.lua b/crops/pumpkin.lua index 2d0bcda..bd7c2cb 100644 --- a/crops/pumpkin.lua +++ b/crops/pumpkin.lua @@ -48,7 +48,7 @@ minetest.register_node("farming:jackolantern", { handy = 1, snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 }, is_ground_content = false, - sounds = farming.sounds.node_sound_wood_defaults(), + sounds = farming.node_sound_wood_defaults(), on_punch = function(pos, node, puncher) local name = puncher:get_player_name() or "" if minetest.is_protected(pos, name) then return end @@ -75,7 +75,7 @@ minetest.register_node("farming:jackolantern_on", { not_in_creative_inventory = 1 }, is_ground_content = false, - sounds = farming.sounds.node_sound_wood_defaults(), + sounds = farming.node_sound_wood_defaults(), drop = "farming:jackolantern", on_punch = function(pos, node, puncher) local name = puncher:get_player_name() or "" @@ -171,7 +171,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 @@ -215,7 +215,7 @@ minetest.register_node("farming:pumpkin_8", { }, is_ground_content = false, drop = "farming:pumpkin_8", - sounds = farming.sounds.node_sound_wood_defaults(), + sounds = farming.node_sound_wood_defaults(), paramtype2 = "facedir", on_place = minetest.rotate_node, _mcl_hardness = 0.8, diff --git a/crops/raspberry.lua b/crops/raspberry.lua index 5434a71..7ac55cb 100644 --- a/crops/raspberry.lua +++ b/crops/raspberry.lua @@ -53,7 +53,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/rhubarb.lua b/crops/rhubarb.lua index 7304886..f34066f 100644 --- a/crops/rhubarb.lua +++ b/crops/rhubarb.lua @@ -54,7 +54,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), minlight = 10, maxlight = 12 } diff --git a/crops/rice.lua b/crops/rice.lua index 6cfef8a..9d5e7ba 100644 --- a/crops/rice.lua +++ b/crops/rice.lua @@ -95,7 +95,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/soy.lua b/crops/soy.lua index 0c5a202..c02761c 100644 --- a/crops/soy.lua +++ b/crops/soy.lua @@ -33,7 +33,7 @@ minetest.register_node("farming:soy_sauce", { compostability = 65 }, is_ground_content = false, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) -- soy sauce recipe @@ -68,7 +68,7 @@ minetest.register_node("farming:soy_milk", { attached_node = 1, drink = 1, compostability = 65 }, is_ground_content = false, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) farming.add_eatable("farming:soy_milk", 2) @@ -143,7 +143,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/spinach.lua b/crops/spinach.lua index ea4019e..e266306 100644 --- a/crops/spinach.lua +++ b/crops/spinach.lua @@ -33,7 +33,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/strawberry.lua b/crops/strawberry.lua index 60f763d..9db91b1 100644 --- a/crops/strawberry.lua +++ b/crops/strawberry.lua @@ -36,7 +36,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } --stage 1 diff --git a/crops/sunflower.lua b/crops/sunflower.lua index 339465a..586bcb5 100644 --- a/crops/sunflower.lua +++ b/crops/sunflower.lua @@ -80,7 +80,7 @@ minetest.register_node("farming:sunflower_oil", { food_oil = 1, vessel = 1, dig_immediate = 3, attached_node = 1, flammable = 2, compostability = 65 }, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) minetest.register_craft( { @@ -137,7 +137,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/tomato.lua b/crops/tomato.lua index f3a88a3..89c9ab7 100644 --- a/crops/tomato.lua +++ b/crops/tomato.lua @@ -55,7 +55,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/crops/vanilla.lua b/crops/vanilla.lua index ed47fa7..e4597d9 100644 --- a/crops/vanilla.lua +++ b/crops/vanilla.lua @@ -34,7 +34,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- vanilla extract @@ -52,7 +52,7 @@ minetest.register_node("farming:vanilla_extract", { fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} }, groups = {vessel = 1, dig_immediate = 3, attached_node = 1}, - sounds = farming.sounds.node_sound_glass_defaults(), + sounds = farming.node_sound_glass_defaults(), }) minetest.register_craft( { diff --git a/crops/wheat.lua b/crops/wheat.lua index f166dd3..c1abb78 100644 --- a/crops/wheat.lua +++ b/crops/wheat.lua @@ -41,7 +41,7 @@ minetest.register_node("farming:straw", { tiles = {"farming_straw.png"}, is_ground_content = false, groups = {handy = 1, snappy = 3, flammable = 4, fall_damage_add_percent = -30}, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), _mcl_hardness = 0.8, _mcl_blast_resistance = 1 }) @@ -69,7 +69,7 @@ if minetest.global_exists("stairs") then {snappy = 3, flammable = 4}, {"farming_straw.png"}, "Straw", - farming.sounds.node_sound_leaves_defaults()) + farming.node_sound_leaves_defaults()) else stairs.register_stair_and_slab("straw", "farming:straw", @@ -77,7 +77,7 @@ if minetest.global_exists("stairs") then {"farming_straw.png"}, "Straw Stair", "Straw Slab", - farming.sounds.node_sound_leaves_defaults()) + farming.node_sound_leaves_defaults()) end end @@ -133,7 +133,7 @@ local def = { }, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults() + sounds = farming.node_sound_leaves_defaults() } -- stage 1 diff --git a/food.lua b/food.lua index 3b57b36..878b2b7 100644 --- a/food.lua +++ b/food.lua @@ -144,7 +144,7 @@ minetest.register_node("farming:sugar_cube", { groups = {shovely = 1, handy = 1, crumbly = 2}, is_ground_content = false, floodable = true, - sounds = farming.sounds.node_sound_gravel_defaults(), + sounds = farming.node_sound_gravel_defaults(), _mcl_hardness = 0.8, _mcl_blast_resistance = 1 }) @@ -190,7 +190,7 @@ minetest.register_node("farming:salt", { tiles = {"farming_salt.png"}, groups = {food_salt = 1, vessel = 1, dig_immediate = 3, attached_node = 1}, is_ground_content = false, - sounds = farming.sounds.node_sound_defaults(), + sounds = farming.node_sound_defaults(), selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} @@ -259,7 +259,7 @@ minetest.register_node("farming:salt_crystal", { tiles = {"farming_salt_crystal.png"}, groups = {dig_immediate = 3, attached_node = 1}, is_ground_content = false, - sounds = farming.sounds.node_sound_defaults(), + sounds = farming.node_sound_defaults(), selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} @@ -305,7 +305,7 @@ minetest.register_node("farming:mayonnaise", { compostability = 65, food_mayonnaise = 1, vessel = 1, dig_immediate = 3, attached_node = 1 }, - sounds = farming.sounds.node_sound_glass_defaults() + sounds = farming.node_sound_glass_defaults() }) farming.add_eatable("farming:mayonnaise", 3) @@ -333,7 +333,7 @@ minetest.register_node("farming:rose_water", { food_rose_water = 1, vessel = 1, dig_immediate = 3, attached_node = 1 }, is_ground_content = false, - sounds = farming.sounds.node_sound_defaults(), + sounds = farming.node_sound_defaults(), selection_box = { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.3, 0.25} diff --git a/init.lua b/init.lua index b0a72a0..0a17b8d 100644 --- a/init.lua +++ b/init.lua @@ -7,15 +7,13 @@ farming = { mod = "redo", - version = "20240803", + version = "20240811", path = minetest.get_modpath("farming"), select = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5} + type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5} }, select_final = { - type = "fixed", - fixed = {-0.5, -0.5, -0.5, 0.5, -2.5/16, 0.5} + type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, -2.5/16, 0.5} }, registered_plants = {}, min_light = 12, @@ -24,21 +22,30 @@ farming = { use_utensils = minetest.settings:get_bool("farming_use_utensils") ~= false, mtg = minetest.get_modpath("default"), mcl = minetest.get_modpath("mcl_core"), - sounds = {}, mcl_hardness = 0.01 } --- default sound functions just incase -function farming.sounds.node_sound_defaults() end -function farming.sounds.node_sound_glass_defaults() end -function farming.sounds.node_sound_gravel_defaults() end -function farming.sounds.node_sound_leaves_defaults() end -function farming.sounds.node_sound_stone_defaults() end -function farming.sounds.node_sound_wood_defaults() end +-- determine which sounds to use, default or mcl_sounds + +local function sound_helper(snd) + + farming[snd] = (farming.mtg and default[snd]) or (farming.mcl and mcl_sounds[snd]) + or function() return {} end +end + +sound_helper("node_sound_defaults") +sound_helper("node_sound_stone_defaults") +sound_helper("node_sound_dirt_defaults") +sound_helper("node_sound_sand_defaults") +sound_helper("node_sound_gravel_defaults") +sound_helper("node_sound_wood_defaults") +sound_helper("node_sound_leaves_defaults") +sound_helper("node_sound_ice_defaults") +sound_helper("node_sound_metal_defaults") +sound_helper("node_sound_water_defaults") +sound_helper("node_sound_snow_defaults") +sound_helper("node_sound_glass_defaults") --- sounds check -if farming.mtg then farming.sounds = default end -if farming.mcl then farming.sounds = mcl_sounds end -- check for creative mode or priv local creative_mode_cache = minetest.settings:get_bool("creative_mode") @@ -689,7 +696,7 @@ farming.register_plant = function(name, def) groups = g, _mcl_hardness = farming.mcl_hardness, is_ground_content = false, - sounds = farming.sounds.node_sound_leaves_defaults(), + sounds = farming.node_sound_leaves_defaults(), minlight = def.minlight, maxlight = def.maxlight, next_plant = next_plant