From 75e3f9fb425331e3e9346ed7fc990a9304e95660 Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Fri, 26 Jul 2024 16:30:53 +0100 Subject: [PATCH] add helper function to add {eatable} --- compatibility.lua | 39 ++++------- crops/artichoke.lua | 6 +- crops/asparagus.lua | 6 +- crops/beans.lua | 6 +- crops/beetroot.lua | 12 ++-- crops/blackberry.lua | 6 +- crops/blueberry.lua | 18 +++-- crops/cabbage.lua | 6 +- crops/carrot.lua | 18 +++-- crops/chili.lua | 12 ++-- crops/cocoa.lua | 12 ++-- crops/coffee.lua | 6 +- crops/corn.lua | 18 +++-- crops/cucumber.lua | 6 +- crops/eggplant.lua | 6 +- crops/garlic.lua | 6 +- crops/ginger.lua | 6 +- crops/grapes.lua | 6 +- crops/lettuce.lua | 6 +- crops/melon.lua | 6 +- crops/mint.lua | 6 +- crops/onion.lua | 12 ++-- crops/parsley.lua | 6 +- crops/peas.lua | 13 ++-- crops/pepper.lua | 18 +++-- crops/pineapple.lua | 12 ++-- crops/potato.lua | 18 +++-- crops/pumpkin.lua | 12 ++-- crops/raspberry.lua | 12 ++-- crops/rhubarb.lua | 12 ++-- crops/rice.lua | 6 +- crops/ryeoatrice.lua | 6 +- crops/soy.lua | 18 +++-- crops/spinach.lua | 6 +- crops/strawberry.lua | 7 +- crops/sunflower.lua | 12 ++-- crops/tomato.lua | 12 ++-- crops/vanilla.lua | 6 +- crops/wheat.lua | 6 +- food.lua | 162 ++++++++++++++++++++++++++++--------------- init.lua | 23 +++++- 41 files changed, 387 insertions(+), 205 deletions(-) diff --git a/compatibility.lua b/compatibility.lua index 7c117b5..a476621 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -8,29 +8,12 @@ local alias = function(orig, new) minetest.register_alias(orig, new) end ---= Add {eatable} group to default apple, blueberries and brown mushroom - -local function add_grp(item, hp) - - local def = minetest.registered_items[item] - - if def then - - def.groups.eatable = hp - def.description = def.description .. " (♥" .. hp .. ")" - - minetest.override_item(item, { - description = def.description, - groups = def.groups - }) - end -end - -add_grp("default:apple", 2) -add_grp("default:blueberries", 1) -add_grp("flowers:mushroom_brown", 1) -add_grp("flowers:mushroom_red", -5) +--= Add {eatable} group to default food items if found +farming.add_eatable("default:apple", 2) +farming.add_eatable("default:blueberries", 1) +farming.add_eatable("flowers:mushroom_brown", 1) +farming.add_eatable("flowers:mushroom_red", -5) --= Aliases @@ -41,7 +24,7 @@ if eth then alias("farming_plus:banana", "ethereal:banana") else minetest.register_node(":ethereal:banana", { - description = S("Banana") .. " (♥2)", + description = S("Banana"), drawtype = "torchlike", tiles = {"farming_banana_single.png"}, inventory_image = "farming_banana_single.png", @@ -54,13 +37,15 @@ else fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2} }, groups = { - food_banana = 1, fleshy = 3, dig_immediate = 3, flammable = 2, eatable = 2 + food_banana = 1, fleshy = 3, dig_immediate = 3 }, is_ground_content = false, on_use = minetest.item_eat(2), sounds = farming.sounds.node_sound_leaves_defaults() }) + farming.add_eatable("ethereal:banana", 2) + minetest.register_node(":ethereal:bananaleaves", { description = S("Banana Leaves"), tiles = {"farming_banana_leaf.png"}, @@ -103,7 +88,7 @@ if eth then alias("farming_plus:orange_seed", "ethereal:orange_tree_sapling") else minetest.register_node(":ethereal:orange", { - description = S("Orange") .. " (♥4)", + description = S("Orange"), drawtype = "plantlike", tiles = {"farming_orange.png"}, inventory_image = "farming_orange.png", @@ -116,13 +101,15 @@ else fixed = {-0.2, -0.3, -0.2, 0.2, 0.2, 0.2} }, groups = { - food_orange = 1, fleshy = 3, dig_immediate = 3, flammable = 2, eatable = 4 + food_orange = 1, fleshy = 3, dig_immediate = 3, flammable = 2 }, is_ground_content = false, on_use = minetest.item_eat(4), sounds = farming.sounds.node_sound_leaves_defaults() }) + farming.add_eatable("ethereal:orange", 4) + alias("farming_plus:orange_item", "ethereal:orange") alias("farming_plus:orange", "ethereal:orange") alias("farming_plus:orange_seed", "default:sapling") diff --git a/crops/artichoke.lua b/crops/artichoke.lua index a366300..ba95d90 100644 --- a/crops/artichoke.lua +++ b/crops/artichoke.lua @@ -3,10 +3,10 @@ local S = farming.translate -- item definition minetest.register_craftitem("farming:artichoke", { - description = S("Artichoke") .. " (♥4)", + description = S("Artichoke"), inventory_image = "farming_artichoke.png", groups = { - compostability = 48, seed = 2, food_artichoke = 1, flammable = 2, eatable = 4 + compostability = 48, seed = 2, food_artichoke = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:artichoke_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:artichoke", { on_use = minetest.item_eat(4) }) +farming.add_eatable("farming:artichoke", 4) + -- crop definition local def = { drawtype = "plantlike", diff --git a/crops/asparagus.lua b/crops/asparagus.lua index ddba6a7..1af5a7b 100644 --- a/crops/asparagus.lua +++ b/crops/asparagus.lua @@ -3,10 +3,10 @@ local S = farming.translate -- asparagus minetest.register_craftitem("farming:asparagus", { - description = S("Asparagus") .. " (♥1)", + description = S("Asparagus"), inventory_image = "farming_asparagus.png", groups = { - compostability = 48, seed = 2, food_asparagus = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_asparagus = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:asparagus_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:asparagus", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:asparagus", 1) + -- asparagus definition local def = { drawtype = "plantlike", diff --git a/crops/beans.lua b/crops/beans.lua index 61ec21a..c582598 100644 --- a/crops/beans.lua +++ b/crops/beans.lua @@ -70,15 +70,17 @@ end -- beans minetest.register_craftitem("farming:beans", { - description = S("Green Beans" .. " (♥1)"), + description = S("Green Beans"), inventory_image = "farming_beans.png", - groups = {compostability = 48, seed = 2, food_beans = 1, flammable = 2, eatable = 1}, + groups = {compostability = 48, seed = 2, food_beans = 1, flammable = 2}, on_use = minetest.item_eat(1), on_place = function(itemstack, placer, pointed_thing) return place_beans(itemstack, placer, pointed_thing, "farming:beanpole_1") end }) +farming.add_eatable("farming:beans", 1) + -- beans can be used for green dye minetest.register_craft({ output = a.dye_green, diff --git a/crops/beetroot.lua b/crops/beetroot.lua index 23e10b9..d4a10b5 100644 --- a/crops/beetroot.lua +++ b/crops/beetroot.lua @@ -4,10 +4,10 @@ local a = farming.recipe_items -- beetroot minetest.register_craftitem("farming:beetroot", { - description = S("Beetroot") .. " (♥1)", + description = S("Beetroot"), inventory_image = "farming_beetroot.png", groups = { - compostability = 48, seed = 2, food_beetroot = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_beetroot = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:beetroot_1") @@ -15,14 +15,18 @@ minetest.register_craftitem("farming:beetroot", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:beetroot", 1) + -- beetroot soup minetest.register_craftitem("farming:beetroot_soup", { - description = S("Beetroot Soup") .. " (♥6)", + description = S("Beetroot Soup"), inventory_image = "farming_beetroot_soup.png", - groups = {flammable = 2, eatable = 6}, + groups = {flammable = 2}, on_use = minetest.item_eat(6, "farming:bowl") }) +farming.add_eatable("farming:beetroot_soup", 6) + minetest.register_craft({ output = "farming:beetroot_soup", recipe = { diff --git a/crops/blackberry.lua b/crops/blackberry.lua index c90e956..e041930 100644 --- a/crops/blackberry.lua +++ b/crops/blackberry.lua @@ -3,11 +3,11 @@ local S = farming.translate -- blackberries minetest.register_craftitem("farming:blackberry", { - description = S("Blackberries" .. " (♥1)"), + description = S("Blackberries"), inventory_image = "farming_blackberry.png", groups = { compostability = 48, seed = 2, food_blackberries = 1, food_blackberry = 1, - food_berry = 1, flammable = 2, eatable = 1 + food_berry = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:blackberry_1") @@ -15,6 +15,8 @@ minetest.register_craftitem("farming:blackberry", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:blackberry", 1) + local def = { drawtype = "plantlike", tiles = {"farming_blackberry_1.png"}, diff --git a/crops/blueberry.lua b/crops/blueberry.lua index 11708e0..9a6aaa0 100644 --- a/crops/blueberry.lua +++ b/crops/blueberry.lua @@ -4,11 +4,11 @@ local a = farming.recipe_items -- blueberries minetest.register_craftitem("farming:blueberries", { - description = S("Wild Blueberries") .. " (♥1)", + description = S("Wild Blueberries"), inventory_image = "farming_blueberries.png", groups = { compostability = 48,seed = 2, food_blueberries = 1, food_blueberry = 1, - food_berry = 1, flammable = 2, eatable = 1 + food_berry = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:blueberry_1") @@ -16,14 +16,18 @@ minetest.register_craftitem("farming:blueberries", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:blueberries", 1) + -- blueberry muffin (thanks to sosogirl123 @ deviantart.com for muffin image) minetest.register_craftitem("farming:muffin_blueberry", { - description = S("Blueberry Muffin") .. " (♥2)", + description = S("Blueberry Muffin"), inventory_image = "farming_blueberry_muffin.png", on_use = minetest.item_eat(2), - groups = {compostability = 65, eatable = 2} + groups = {compostability = 65} }) +farming.add_eatable("farming:muffin_blueberry", 2) + minetest.register_craft({ output = "farming:muffin_blueberry 2", recipe = { @@ -33,12 +37,14 @@ minetest.register_craft({ -- Blueberry Pie minetest.register_craftitem("farming:blueberry_pie", { - description = S("Blueberry Pie") .. " (♥6)", + description = S("Blueberry Pie"), inventory_image = "farming_blueberry_pie.png", on_use = minetest.item_eat(6), - groups = {compostability = 75, eatable = 6} + groups = {compostability = 75} }) +farming.add_eatable("farming:blueberry_pie", 6) + minetest.register_craft({ output = "farming:blueberry_pie", recipe = { diff --git a/crops/cabbage.lua b/crops/cabbage.lua index 8bec347..09c878d 100644 --- a/crops/cabbage.lua +++ b/crops/cabbage.lua @@ -3,10 +3,10 @@ local S = farming.translate -- cabbage minetest.register_craftitem("farming:cabbage", { - description = S("Cabbage") .. " (♥1)", + description = S("Cabbage"), inventory_image = "farming_cabbage.png", groups = { - compostability = 48, seed = 2, food_cabbage = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_cabbage = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:cabbage_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:cabbage", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:cabbage", 1) + local def = { drawtype = "plantlike", tiles = {"farming_cabbage_1.png"}, diff --git a/crops/carrot.lua b/crops/carrot.lua index 7313010..f00be26 100644 --- a/crops/carrot.lua +++ b/crops/carrot.lua @@ -9,10 +9,10 @@ local a = farming.recipe_items -- carrot minetest.register_craftitem("farming:carrot", { - description = S("Carrot") .. " (♥4)", + description = S("Carrot"), inventory_image = "farming_carrot.png", groups = { - compostability = 48, seed = 2, food_carrot = 1, flammable = 2, eatable = 4 + compostability = 48, seed = 2, food_carrot = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:carrot_1") @@ -20,14 +20,18 @@ minetest.register_craftitem("farming:carrot", { on_use = minetest.item_eat(4) }) +farming.add_eatable("farming:carrot", 4) + -- carrot juice minetest.register_craftitem("farming:carrot_juice", { - description = S("Carrot Juice") .. " (♥4)", + description = S("Carrot Juice"), inventory_image = "farming_carrot_juice.png", on_use = minetest.item_eat(4, "vessels:drinking_glass"), - groups = {vessel = 1, drink = 1, eatable = 4} + groups = {vessel = 1, drink = 1} }) +farming.add_eatable("farming:carrot_juice", 4) + minetest.register_craft({ output = "farming:carrot_juice", recipe = { @@ -42,12 +46,14 @@ minetest.register_craft({ -- golden carrot minetest.register_craftitem("farming:carrot_gold", { - description = S("Golden Carrot") .. " (♥10)", + description = S("Golden Carrot"), inventory_image = "farming_carrot_gold.png", on_use = minetest.item_eat(10), - groups = {eatable = 10} + groups = {flammable = 2} }) +farming.add_eatable("farming:carrot_gold", 10) + minetest.register_craft({ output = "farming:carrot_gold", recipe = {{"group:food_carrot", "default:gold_lump"}} diff --git a/crops/chili.lua b/crops/chili.lua index d8484e5..b5e2e0d 100644 --- a/crops/chili.lua +++ b/crops/chili.lua @@ -4,10 +4,10 @@ local a = farming.recipe_items -- chili pepper minetest.register_craftitem("farming:chili_pepper", { - description = S("Chili Pepper") .. " (♥2)", + description = S("Chili Pepper"), inventory_image = "farming_chili_pepper.png", groups = { - compostability = 48, seed = 2, food_chili_pepper = 1, flammable = 4, eatable = 2 + compostability = 48, seed = 2, food_chili_pepper = 1, flammable = 4 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:chili_1") @@ -15,14 +15,18 @@ minetest.register_craftitem("farming:chili_pepper", { on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:chili_pepper", 2) + -- bowl of chili minetest.register_craftitem("farming:chili_bowl", { - description = S("Bowl of Chili") .. " (♥8)", + description = S("Bowl of Chili"), inventory_image = "farming_chili_bowl.png", on_use = minetest.item_eat(8, a.bowl), - groups = {compostability = 65, eatable = 8} + groups = {compostability = 65} }) +farming.add_eatable("farming:chili_bowl", 8) + minetest.register_craft({ output = "farming:chili_bowl", recipe = { diff --git a/crops/cocoa.lua b/crops/cocoa.lua index 75abbed..0f80233 100644 --- a/crops/cocoa.lua +++ b/crops/cocoa.lua @@ -94,12 +94,14 @@ minetest.register_craft( { -- chocolate cookie minetest.register_craftitem("farming:cookie", { - description = S("Cookie") .. " (♥2)", + description = S("Cookie"), inventory_image = "farming_cookie.png", on_use = minetest.item_eat(2), - groups = {eatable = 2} + groups = {flammable = 2} }) +farming.add_eatable("farming:cookie", 2) + minetest.register_craft( { output = "farming:cookie 8", recipe = { @@ -109,12 +111,14 @@ minetest.register_craft( { -- bar of dark chocolate (thanks to Ice Pandora for her deviantart.com chocolate tutorial) minetest.register_craftitem("farming:chocolate_dark", { - description = S("Bar of Dark Chocolate") .. " (♥3)", + description = S("Bar of Dark Chocolate"), inventory_image = "farming_chocolate_dark.png", on_use = minetest.item_eat(3), - groups = {eatable = 3} + groups = {flammable = 2} }) +farming.add_eatable("farming:chocolate_dark", 3) + minetest.register_craft( { output = "farming:chocolate_dark", recipe = { diff --git a/crops/coffee.lua b/crops/coffee.lua index 9c04236..3230dc9 100644 --- a/crops/coffee.lua +++ b/crops/coffee.lua @@ -14,7 +14,7 @@ minetest.register_craftitem("farming:coffee_beans", { -- cup of coffee minetest.register_node("farming:coffee_cup", { - description = S("Cup of Coffee") .. " (♥2)", + description = S("Cup of Coffee"), drawtype = "torchlike", tiles = {"farming_coffee_cup.png"}, inventory_image = "farming_coffee_cup.png", @@ -25,12 +25,14 @@ minetest.register_node("farming:coffee_cup", { type = "fixed", fixed = {-0.25, -0.5, -0.25, 0.25, 0.25, 0.25} }, - groups = {vessel = 1, dig_immediate = 3, attached_node = 1, drink = 1, eatable = 2}, + 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() }) +farming.add_eatable("farming:coffee_cup", 2) + minetest.register_alias("farming:coffee_cup_hot", "farming:coffee_cup") minetest.register_alias("farming:drinking_cup", "vessels:drinking_glass") diff --git a/crops/corn.lua b/crops/corn.lua index f5a87be..5e650d2 100644 --- a/crops/corn.lua +++ b/crops/corn.lua @@ -9,10 +9,10 @@ local a = farming.recipe_items -- corn minetest.register_craftitem("farming:corn", { - description = S("Corn") .. " (♥3)", + description = S("Corn"), inventory_image = "farming_corn.png", groups = { - compostability = 45, seed = 2, food_corn = 1, flammable = 2, eatable = 3 + compostability = 45, seed = 2, food_corn = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:corn_1") @@ -20,14 +20,18 @@ minetest.register_craftitem("farming:corn", { on_use = minetest.item_eat(3) }) +farming.add_eatable("farming:corn", 3) + -- corn on the cob (texture by TenPlus1) minetest.register_craftitem("farming:corn_cob", { - description = S("Corn on the Cob") .. " (♥5)", + description = S("Corn on the Cob"), inventory_image = "farming_corn_cob.png", - groups = {compostability = 65, food_corn_cooked = 1, flammable = 2, eatable = 5}, + groups = {compostability = 65, food_corn_cooked = 1, flammable = 2}, on_use = minetest.item_eat(5) }) +farming.add_eatable("farming:corn_cob", 5) + minetest.register_craft({ type = "cooking", cooktime = 10, @@ -37,12 +41,14 @@ minetest.register_craft({ -- popcorn minetest.register_craftitem("farming:popcorn", { - description = S("Popcorn") .. " (♥4)", + description = S("Popcorn"), inventory_image = "farming_popcorn.png", - groups = {compostability = 55, food_popcorn = 1, flammable = 2, eatable = 4}, + groups = {compostability = 55, food_popcorn = 1, flammable = 2}, on_use = minetest.item_eat(4) }) +farming.add_eatable("farming:popcorn", 4) + minetest.register_craft({ output = "farming:popcorn", recipe = { diff --git a/crops/cucumber.lua b/crops/cucumber.lua index f207395..58b65ae 100644 --- a/crops/cucumber.lua +++ b/crops/cucumber.lua @@ -8,10 +8,10 @@ local S = farming.translate -- cucumber minetest.register_craftitem("farming:cucumber", { - description = S("Cucumber") .. " (♥4)", + description = S("Cucumber"), inventory_image = "farming_cucumber.png", groups = { - compostability = 48, seed = 2, food_cucumber = 1, flammable = 2, eatable = 4 + compostability = 48, seed = 2, food_cucumber = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:cucumber_1") @@ -19,6 +19,8 @@ minetest.register_craftitem("farming:cucumber", { on_use = minetest.item_eat(4) }) +farming.add_eatable("farming:cucumber", 4) + -- cucumber definition local def = { drawtype = "plantlike", diff --git a/crops/eggplant.lua b/crops/eggplant.lua index c923772..9dec3d1 100644 --- a/crops/eggplant.lua +++ b/crops/eggplant.lua @@ -3,10 +3,10 @@ local S = farming.translate -- eggplant minetest.register_craftitem("farming:eggplant", { - description = S("Eggplant") .. " (♥3)", + description = S("Eggplant"), inventory_image = "farming_eggplant.png", groups = { - compostability = 48, seed = 2, food_eggplant = 1, flammable = 2, eatable = 3 + compostability = 48, seed = 2, food_eggplant = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:eggplant_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:eggplant", { on_use = minetest.item_eat(3) }) +farming.add_eatable("farming:eggplant", 3) + -- definition local def = { drawtype = "plantlike", diff --git a/crops/garlic.lua b/crops/garlic.lua index ce76922..dbcfbfb 100644 --- a/crops/garlic.lua +++ b/crops/garlic.lua @@ -13,12 +13,14 @@ minetest.register_craftitem("farming:garlic_clove", { -- garlic bulb minetest.register_craftitem("farming:garlic", { - description = S("Garlic") .. " (♥1)", + description = S("Garlic"), inventory_image = "crops_garlic.png", on_use = minetest.item_eat(1), - groups = {food_garlic = 1, flammable = 3, compostability = 55, eatable = 1} + groups = {food_garlic = 1, flammable = 3, compostability = 55} }) +farming.add_eatable("farming:garlic", 1) + minetest.register_craft({ output = "farming:garlic_clove 8", recipe = {{"farming:garlic"}} diff --git a/crops/ginger.lua b/crops/ginger.lua index e161c7a..9081074 100644 --- a/crops/ginger.lua +++ b/crops/ginger.lua @@ -3,10 +3,10 @@ local S = farming.translate -- ginger minetest.register_craftitem("farming:ginger", { - description = S("Ginger") .. " (♥1)", + description = S("Ginger"), inventory_image = "farming_ginger.png", groups = { - compostability = 48, seed = 2, food_ginger = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_ginger = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:ginger_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:ginger", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:ginger", 1) + -- ginger definition local def = { drawtype = "plantlike", diff --git a/crops/grapes.lua b/crops/grapes.lua index 6445323..851a4ea 100644 --- a/crops/grapes.lua +++ b/crops/grapes.lua @@ -65,17 +65,19 @@ end -- grapes minetest.register_craftitem("farming:grapes", { - description = S("Grapes") .. " (♥2)", + description = S("Grapes"), inventory_image = "farming_grapes.png", on_use = minetest.item_eat(2), groups = { - compostability = 48, seed = 2, food_grapes = 1, flammable = 3, eatable = 2 + compostability = 48, seed = 2, food_grapes = 1, flammable = 3 }, on_place = function(itemstack, placer, pointed_thing) return place_grapes(itemstack, placer, pointed_thing, "farming:grapes_1") end }) +farming.add_eatable("farming:grapes", 2) + -- grapes can be used for violet dye minetest.register_craft({ output = a.dye_violet, diff --git a/crops/lettuce.lua b/crops/lettuce.lua index 268cca1..6c2365d 100644 --- a/crops/lettuce.lua +++ b/crops/lettuce.lua @@ -3,10 +3,10 @@ local S = farming.translate -- lettuce minetest.register_craftitem("farming:lettuce", { - description = S("Lettuce") .. " (♥2)", + description = S("Lettuce"), inventory_image = "farming_lettuce.png", groups = { - compostability = 48, seed = 2, food_lettuce = 1, flammable = 2, eatable = 2 + compostability = 48, seed = 2, food_lettuce = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:lettuce_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:lettuce", { on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:lettuce", 2) + local def = { drawtype = "plantlike", tiles = {"farming_lettuce_1.png"}, diff --git a/crops/melon.lua b/crops/melon.lua index 8e16e50..c5c74b3 100644 --- a/crops/melon.lua +++ b/crops/melon.lua @@ -4,10 +4,10 @@ local a = farming.recipe_items -- melon minetest.register_craftitem("farming:melon_slice", { - description = S("Melon Slice") .. " (♥2)", + description = S("Melon Slice"), inventory_image = "farming_melon_slice.png", groups = { - compostability = 48, seed = 2, food_melon_slice = 1, flammable = 3, eatable = 2 + compostability = 48, seed = 2, food_melon_slice = 1, flammable = 3 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:melon_1") @@ -15,6 +15,8 @@ minetest.register_craftitem("farming:melon_slice", { on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:melon_slice", 2) + minetest.register_craft({ output = "farming:melon_8", recipe = { diff --git a/crops/mint.lua b/crops/mint.lua index da39cc2..038c7b1 100644 --- a/crops/mint.lua +++ b/crops/mint.lua @@ -38,12 +38,14 @@ minetest.register_craftitem("farming:mint_leaf", { -- mint tea minetest.register_craftitem("farming:mint_tea", { - description = S("Mint Tea") .. " (♥2)", + description = S("Mint Tea"), inventory_image = "farming_mint_tea.png", on_use = minetest.item_eat(2, a.drinking_glass), - groups = {flammable = 4, eatable = 2} + groups = {flammable = 4} }) +farming.add_eatable("farming:mint_tea", 2) + minetest.register_craft({ output = "farming:mint_tea", recipe = { diff --git a/crops/onion.lua b/crops/onion.lua index c849b31..ef5250f 100644 --- a/crops/onion.lua +++ b/crops/onion.lua @@ -10,10 +10,10 @@ local a = farming.recipe_items -- onion minetest.register_craftitem("farming:onion", { - description = S("Onion") .. " (♥1)", + description = S("Onion"), inventory_image = "crops_onion.png", groups = { - compostability = 48, seed = 2, food_onion = 1, flammable = 3, eatable = 1 + compostability = 48, seed = 2, food_onion = 1, flammable = 3 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:onion_1") @@ -21,14 +21,18 @@ minetest.register_craftitem("farming:onion", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:onion", 1) + -- onion soup minetest.register_craftitem("farming:onion_soup", { - description = S("Onion Soup") .. " (♥6)", + description = S("Onion Soup"), inventory_image = "farming_onion_soup.png", - groups = {flammable = 2, compostability = 65, eatable = 6}, + groups = {flammable = 2, compostability = 65}, on_use = minetest.item_eat(6, a.bowl) }) +farming.add_eatable("farming:onion_soup", 6) + minetest.register_craft({ output = "farming:onion_soup", recipe = { diff --git a/crops/parsley.lua b/crops/parsley.lua index beb92f4..bfb679a 100644 --- a/crops/parsley.lua +++ b/crops/parsley.lua @@ -3,10 +3,10 @@ local S = farming.translate -- item definition minetest.register_craftitem("farming:parsley", { - description = S("Parsley") .. " (♥1)", + description = S("Parsley"), inventory_image = "farming_parsley.png", groups = { - compostability = 48, seed = 2, food_parsley = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_parsley = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:parsley_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:parsley", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:parsley", 1) + -- crop definition local def = { drawtype = "plantlike", diff --git a/crops/peas.lua b/crops/peas.lua index c242abe..ef49d7c 100644 --- a/crops/peas.lua +++ b/crops/peas.lua @@ -6,11 +6,10 @@ local a = farming.recipe_items -- pea pod minetest.register_craftitem("farming:pea_pod", { - description = S("Pea Pod") .. " (♥1)", + description = S("Pea Pod"), inventory_image = "farming_pea_pod.png", groups = { - compostability = 48, seed = 2, food_peas = 1, food_pea_pod = 1, flammable = 2, - eatable = 1 + compostability = 48, seed = 2, food_peas = 1, food_pea_pod = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:pea_1") @@ -18,17 +17,21 @@ minetest.register_craftitem("farming:pea_pod", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:pea_pod", 1) + -- replacement for separate peas item that was removed minetest.register_alias("farming:peas", "farming:pea_pod") -- pea soup minetest.register_craftitem("farming:pea_soup", { - description = S("Pea Soup") .. " (♥4)", + description = S("Pea Soup"), inventory_image = "farming_pea_soup.png", - groups = {flammable = 2, compostability = 65, eatable = 4}, + groups = {flammable = 2, compostability = 65}, on_use = minetest.item_eat(4, a.bowl) }) +farming.add_eatable("farming:pea_soup", 4) + minetest.register_craft({ output = "farming:pea_soup", recipe = { diff --git a/crops/pepper.lua b/crops/pepper.lua index 4b187c5..1b0965f 100644 --- a/crops/pepper.lua +++ b/crops/pepper.lua @@ -20,28 +20,34 @@ minetest.register_craftitem("farming:peppercorn", { -- green pepper minetest.register_craftitem("farming:pepper", { - description = S("Green Pepper") .. " (♥2)", + description = S("Green Pepper"), inventory_image = "crops_pepper.png", on_use = minetest.item_eat(2), - groups = {food_pepper = 1, flammable = 3, compostability = 55, eatable = 2} + groups = {food_pepper = 1, flammable = 3, compostability = 55} }) +farming.add_eatable("farming:pepper", 2) + -- yellow pepper minetest.register_craftitem("farming:pepper_yellow", { - description = S("Yellow Pepper") .. " (♥3)", + description = S("Yellow Pepper"), inventory_image = "crops_pepper_yellow.png", on_use = minetest.item_eat(3), - groups = {food_pepper = 1, flammable = 3, compostability = 55, eatable = 3} + groups = {food_pepper = 1, flammable = 3, compostability = 55} }) +farming.add_eatable("farming:pepper_yellow", 3) + -- red pepper minetest.register_craftitem("farming:pepper_red", { - description = S("Red Pepper") .. " (♥3)", + description = S("Red Pepper"), inventory_image = "crops_pepper_red.png", on_use = minetest.item_eat(4), - groups = {food_pepper = 1, flammable = 3, compostability = 55, eatable = 3} + groups = {food_pepper = 1, flammable = 3, compostability = 55} }) +farming.add_eatable("farming:pepper_red", 3) + minetest.register_craft({ output = "farming:peppercorn", recipe = {{"group:food_pepper"}} diff --git a/crops/pineapple.lua b/crops/pineapple.lua index b7f94f0..708e35f 100644 --- a/crops/pineapple.lua +++ b/crops/pineapple.lua @@ -36,12 +36,14 @@ minetest.register_node("farming:pineapple", { -- pineapple minetest.register_craftitem("farming:pineapple_ring", { - description = S("Pineapple Ring") .. " (♥1)", + description = S("Pineapple Ring"), inventory_image = "farming_pineapple_ring.png", - groups = {food_pineapple_ring = 1, flammable = 2, compostability = 45, eatable = 1}, + groups = {food_pineapple_ring = 1, flammable = 2, compostability = 45}, on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:pineapple_ring", 1) + minetest.register_craft( { output = "farming:pineapple_ring 5", recipe = {{"group:food_pineapple"}}, @@ -50,12 +52,14 @@ minetest.register_craft( { -- pineapple juice minetest.register_craftitem("farming:pineapple_juice", { - description = S("Pineapple Juice") .. " (♥4)", + description = S("Pineapple Juice"), inventory_image = "farming_pineapple_juice.png", on_use = minetest.item_eat(4, "vessels:drinking_glass"), - groups = {vessel = 1, drink = 1, compostability = 35, eatable = 4} + groups = {vessel = 1, drink = 1, compostability = 35} }) +farming.add_eatable("farming:pineapple_juice", 4) + minetest.register_craft({ output = "farming:pineapple_juice", recipe = { diff --git a/crops/potato.lua b/crops/potato.lua index 2fa137d..aeb722f 100644 --- a/crops/potato.lua +++ b/crops/potato.lua @@ -8,9 +8,9 @@ local S = farming.translate -- potato minetest.register_craftitem("farming:potato", { - description = S("Potato") .. " (♥1)", + description = S("Potato"), inventory_image = "farming_potato.png", - groups = {compostability = 48, seed = 2, food_potato = 1, flammable = 2, eatable = 1}, + groups = {compostability = 48, seed = 2, food_potato = 1, flammable = 2}, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:potato_1") end, @@ -26,14 +26,18 @@ minetest.register_craftitem("farming:potato", { end }) +farming.add_eatable("farming:potato", 1) + -- baked potato minetest.register_craftitem("farming:baked_potato", { - description = S("Baked Potato") .. " (♥6)", + description = S("Baked Potato"), inventory_image = "farming_baked_potato.png", on_use = minetest.item_eat(6), - groups = {eatable = 6} + groups = {flammable = 2} }) +farming.add_eatable("farming:baked_potato", 6) + minetest.register_craft({ type = "cooking", cooktime = 10, @@ -43,12 +47,14 @@ minetest.register_craft({ -- Potato and cucumber Salad minetest.register_craftitem("farming:potato_salad", { - description = S("Cucumber and Potato Salad") .. " (♥10)", + description = S("Cucumber and Potato Salad"), inventory_image = "farming_potato_salad.png", on_use = minetest.item_eat(10, "farming:bowl"), - groups = {eatable = 10} + groups = {flammable = 2} }) +farming.add_eatable("farming:potato_salad", 10) + minetest.register_craft({ output = "farming:potato_salad", recipe = { diff --git a/crops/pumpkin.lua b/crops/pumpkin.lua index 437864b..524ea93 100644 --- a/crops/pumpkin.lua +++ b/crops/pumpkin.lua @@ -3,10 +3,10 @@ local S = farming.translate -- pumpkin slice minetest.register_craftitem("farming:pumpkin_slice", { - description = S("Pumpkin Slice") .. " (♥2)", + description = S("Pumpkin Slice"), inventory_image = "farming_pumpkin_slice.png", groups = { - compostability = 48, seed = 2, food_pumpkin_slice = 1, flammable = 2, eatable = 2 + compostability = 48, seed = 2, food_pumpkin_slice = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:pumpkin_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:pumpkin_slice", { on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:pumpkin_slice", 2) + minetest.register_craft({ output = "farming:pumpkin", recipe = { @@ -125,12 +127,14 @@ minetest.register_craft({ -- pumpkin bread minetest.register_craftitem("farming:pumpkin_bread", { - description = S("Pumpkin Bread") .. " (♥8)", + description = S("Pumpkin Bread"), inventory_image = "farming_pumpkin_bread.png", on_use = minetest.item_eat(8), - groups = {food_bread = 1, flammable = 2, eatable = 8} + groups = {food_bread = 1, flammable = 2} }) +farming.add_eatable("farming:pumpkin_bread", 8) + minetest.register_craftitem("farming:pumpkin_dough", { description = S("Pumpkin Dough"), inventory_image = "farming_pumpkin_dough.png" diff --git a/crops/raspberry.lua b/crops/raspberry.lua index bae2ac1..8fc986b 100644 --- a/crops/raspberry.lua +++ b/crops/raspberry.lua @@ -4,11 +4,11 @@ local a = farming.recipe_items -- raspberries minetest.register_craftitem("farming:raspberries", { - description = S("Raspberries") .. " (♥1)", + description = S("Raspberries"), inventory_image = "farming_raspberries.png", groups = { compostability = 48, seed = 2, food_raspberries = 1, food_raspberry = 1, - food_berry = 1, flammable = 2, eatable = 1 + food_berry = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:raspberry_1") @@ -16,14 +16,18 @@ minetest.register_craftitem("farming:raspberries", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:raspberries", 1) + -- raspberry smoothie minetest.register_craftitem("farming:smoothie_raspberry", { - description = S("Raspberry Smoothie") .. " (♥2)", + description = S("Raspberry Smoothie"), inventory_image = "farming_raspberry_smoothie.png", on_use = minetest.item_eat(2, "vessels:drinking_glass"), - groups = {vessel = 1, drink = 1, compostability = 65, eatable = 2} + groups = {vessel = 1, drink = 1, compostability = 65} }) +farming.add_eatable("farming:smoothie_raspberry", 2) + minetest.register_craft({ output = "farming:smoothie_raspberry", recipe = { diff --git a/crops/rhubarb.lua b/crops/rhubarb.lua index 65e7cb0..87a250c 100644 --- a/crops/rhubarb.lua +++ b/crops/rhubarb.lua @@ -4,10 +4,10 @@ local a = farming.recipe_items -- rhubarb minetest.register_craftitem("farming:rhubarb", { - description = S("Rhubarb") .. " (♥1)", + description = S("Rhubarb"), inventory_image = "farming_rhubarb.png", groups = { - compostability = 48, seed = 2, food_rhubarb = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_rhubarb = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:rhubarb_1") @@ -15,14 +15,18 @@ minetest.register_craftitem("farming:rhubarb", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:rhubarb", 1) + -- rhubarb pie minetest.register_craftitem("farming:rhubarb_pie", { - description = S("Rhubarb Pie") .. " (♥6)", + description = S("Rhubarb Pie"), inventory_image = "farming_rhubarb_pie.png", on_use = minetest.item_eat(6), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65, flammable = 2} }) +farming.add_eatable("farming:rhubarb_pie", 6) + minetest.register_craft({ output = "farming:rhubarb_pie", recipe = { diff --git a/crops/rice.lua b/crops/rice.lua index 5952d18..6dc2d59 100644 --- a/crops/rice.lua +++ b/crops/rice.lua @@ -46,12 +46,14 @@ minetest.register_craft({ -- rice flour and bread minetest.register_craftitem("farming:rice_bread", { - description = S("Rice Bread") .. " (♥5)", + description = S("Rice Bread"), inventory_image = "farming_rice_bread.png", on_use = minetest.item_eat(5), - groups = {food_rice_bread = 1, flammable = 2, compostability = 65, eatable = 5} + groups = {food_rice_bread = 1, flammable = 2, compostability = 65} }) +farming.add_eatable("farming:rice_bread", 5) + minetest.register_craftitem("farming:rice_flour", { description = S("Rice Flour"), inventory_image = "farming_rice_flour.png", diff --git a/crops/ryeoatrice.lua b/crops/ryeoatrice.lua index 4b63983..81fa8db 100644 --- a/crops/ryeoatrice.lua +++ b/crops/ryeoatrice.lua @@ -81,12 +81,14 @@ minetest.register_craft({ -- Multigrain bread minetest.register_craftitem("farming:bread_multigrain", { - description = S("Multigrain Bread") .. " (♥7)", + description = S("Multigrain Bread"), inventory_image = "farming_bread_multigrain.png", on_use = minetest.item_eat(7), - groups = {food_bread = 1, flammable = 2, compostability = 65, eatable = 7} + groups = {food_bread = 1, flammable = 2, compostability = 65} }) +farming.add_eatable("farming:bread_multigrain", 7) + minetest.register_craft({ type = "cooking", cooktime = 15, diff --git a/crops/soy.lua b/crops/soy.lua index d8300ca..dee9e92 100644 --- a/crops/soy.lua +++ b/crops/soy.lua @@ -51,7 +51,7 @@ minetest.register_craft( { -- soy milk minetest.register_node("farming:soy_milk", { - description = S("Soy Milk") .. " (♥2)", + description = S("Soy Milk"), drawtype = "plantlike", tiles = {"farming_soy_milk_glass.png"}, inventory_image = "farming_soy_milk_glass.png", @@ -64,13 +64,15 @@ minetest.register_node("farming:soy_milk", { }, on_use = minetest.item_eat(2, "vessels:drinking_glass"), groups = { - vessel = 1, food_milk_glass = 1, dig_immediate = 3, eatable = 2, + vessel = 1, food_milk_glass = 1, dig_immediate = 3, attached_node = 1, drink = 1, compostability = 65 }, is_ground_content = false, sounds = farming.sounds.node_sound_glass_defaults() }) +farming.add_eatable("farming:soy_milk", 2) + minetest.register_craft( { output = "farming:soy_milk", recipe = { @@ -85,14 +87,16 @@ minetest.register_craft( { -- tofu minetest.register_craftitem("farming:tofu", { - description = S("Tofu") .. " (♥3)", + description = S("Tofu"), inventory_image = "farming_tofu.png", groups = { - food_tofu = 1, food_meat_raw = 1, flammable = 2, compostability = 65, eatable = 3 + food_tofu = 1, food_meat_raw = 1, flammable = 2, compostability = 65, }, on_use = minetest.item_eat(3) }) +farming.add_eatable("farming:tofu", 3) + minetest.register_craft({ output = "farming:tofu", recipe = { @@ -104,12 +108,14 @@ minetest.register_craft({ -- cooked tofu minetest.register_craftitem("farming:tofu_cooked", { - description = S("Cooked Tofu") .. " (♥6)", + description = S("Cooked Tofu"), inventory_image = "farming_tofu_cooked.png", - groups = {food_meat = 1, flammable = 2, compostability = 65, eatable = 6}, + groups = {food_meat = 1, flammable = 2, compostability = 65}, on_use = minetest.item_eat(6) }) +farming.add_eatable("farming:tofu_cooked", 6) + minetest.register_craft({ type = "cooking", output = "farming:tofu_cooked", diff --git a/crops/spinach.lua b/crops/spinach.lua index fd611b9..d07bf5e 100644 --- a/crops/spinach.lua +++ b/crops/spinach.lua @@ -3,10 +3,10 @@ local S = farming.translate -- spinach minetest.register_craftitem("farming:spinach", { - description = S("Spinach") .. " (♥1)", + description = S("Spinach"), inventory_image = "farming_spinach.png", groups = { - compostability = 48, seed = 2, food_spinach = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_spinach = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:spinach_1") @@ -14,6 +14,8 @@ minetest.register_craftitem("farming:spinach", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:spinach", 1) + -- definition local def = { drawtype = "plantlike", diff --git a/crops/strawberry.lua b/crops/strawberry.lua index a763c4b..77983b6 100644 --- a/crops/strawberry.lua +++ b/crops/strawberry.lua @@ -3,11 +3,10 @@ local S = farming.translate -- Strawberry (can also be planted as seed) minetest.register_craftitem(":ethereal:strawberry", { - description = S("Strawberry") .. " (♥1)", + description = S("Strawberry"), inventory_image = "ethereal_strawberry.png", groups = { - compostability = 48, seed = 2, food_strawberry = 1, food_berry = 1, - flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_strawberry = 1, food_berry = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "ethereal:strawberry_1") @@ -15,6 +14,8 @@ minetest.register_craftitem(":ethereal:strawberry", { on_use = minetest.item_eat(1) }) +farming.add_eatable("ethereal:strawberry", 1) + -- Define Strawberry Bush growth stages local def = { drawtype = "plantlike", diff --git a/crops/sunflower.lua b/crops/sunflower.lua index c21e3bc..9134336 100644 --- a/crops/sunflower.lua +++ b/crops/sunflower.lua @@ -45,14 +45,16 @@ minetest.register_craft({ -- sunflower seeds (toasted) minetest.register_craftitem("farming:sunflower_seeds_toasted", { - description = S("Toasted Sunflower Seeds") .. " (♥1)", + description = S("Toasted Sunflower Seeds"), inventory_image = "farming_sunflower_seeds_toasted.png", groups = { - food_sunflower_seeds_toasted = 1, flammable = 2, compostability = 65, eatable = 1 + food_sunflower_seeds_toasted = 1, flammable = 2, compostability = 65 }, on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:sunflower_seeds_toasted", 1) + minetest.register_craft({ type = "cooking", cooktime = 10, @@ -99,12 +101,14 @@ minetest.register_craft({ -- sunflower seed bread minetest.register_craftitem("farming:sunflower_bread", { - description = S("Sunflower Seed Bread") .. " (♥8)", + description = S("Sunflower Seed Bread"), inventory_image = "farming_sunflower_bread.png", on_use = minetest.item_eat(8), - groups = {food_bread = 1, flammable = 2, eatable = 8} + groups = {food_bread = 1, flammable = 2} }) +farming.add_eatable("farming:sunflower_bread", 8) + minetest.register_craft({ output = "farming:sunflower_bread", recipe = { diff --git a/crops/tomato.lua b/crops/tomato.lua index 51cad19..c1f66c7 100644 --- a/crops/tomato.lua +++ b/crops/tomato.lua @@ -8,23 +8,27 @@ local S = farming.translate -- tomato minetest.register_craftitem("farming:tomato", { - description = S("Tomato") .. " (♥4)", + description = S("Tomato"), inventory_image = "farming_tomato.png", - groups = {compostability = 45, seed = 2, food_tomato = 1, flammable = 2, eatable = 4}, + groups = {compostability = 45, seed = 2, food_tomato = 1, flammable = 2}, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:tomato_1") end, on_use = minetest.item_eat(4) }) +farming.add_eatable("farming:tomato", 4) + -- tomato soup minetest.register_craftitem("farming:tomato_soup", { - description = S("Tomato Soup") .. " (♥8)", + description = S("Tomato Soup"), inventory_image = "farming_tomato_soup.png", - groups = {flammable = 2, compostability = 65, eatable = 8}, + groups = {flammable = 2, compostability = 65}, on_use = minetest.item_eat(8, "farming:bowl") }) +farming.add_eatable("farming:tomato_soup", 8) + minetest.register_craft({ output = "farming:tomato_soup", recipe = { diff --git a/crops/vanilla.lua b/crops/vanilla.lua index a18136d..057f119 100644 --- a/crops/vanilla.lua +++ b/crops/vanilla.lua @@ -4,10 +4,10 @@ local a = farming.recipe_items -- vanilla minetest.register_craftitem("farming:vanilla", { - description = S("Vanilla") .. " (♥1)", + description = S("Vanilla"), inventory_image = "farming_vanilla.png", groups = { - compostability = 48, seed = 2, food_vanilla = 1, flammable = 2, eatable = 1 + compostability = 48, seed = 2, food_vanilla = 1, flammable = 2 }, on_place = function(itemstack, placer, pointed_thing) return farming.place_seed(itemstack, placer, pointed_thing, "farming:vanilla_1") @@ -15,6 +15,8 @@ minetest.register_craftitem("farming:vanilla", { on_use = minetest.item_eat(1) }) +farming.add_eatable("farming:vanilla", 1) + -- crop definition local def = { drawtype = "plantlike", diff --git a/crops/wheat.lua b/crops/wheat.lua index c344062..6e98bb4 100644 --- a/crops/wheat.lua +++ b/crops/wheat.lua @@ -99,12 +99,14 @@ minetest.register_craft({ -- bread minetest.register_craftitem("farming:bread", { - description = S("Bread") .. " (♥5)", + description = S("Bread"), inventory_image = "farming_bread.png", on_use = minetest.item_eat(5), - groups = {food_bread = 1, flammable = 2, eatable = 5} + groups = {food_bread = 1, flammable = 2} }) +farming.add_eatable("farming:bread", 5) + minetest.register_craft({ type = "cooking", cooktime = 15, diff --git a/food.lua b/food.lua index 45c048e..8fc5422 100644 --- a/food.lua +++ b/food.lua @@ -5,12 +5,14 @@ local a = farming.recipe_items -- sliced bread minetest.register_craftitem("farming:bread_slice", { - description = S("Sliced Bread") .. " (♥1)", + description = S("Sliced Bread"), inventory_image = "farming_bread_slice.png", on_use = minetest.item_eat(1), - groups = {food_bread_slice = 1, flammable = 2, compostability = 65, eatable = 1} + groups = {food_bread_slice = 1, compostability = 65} }) +farming.add_eatable("farming:bread_slice", 1) + minetest.register_craft({ output = "farming:bread_slice 5", recipe = {{"group:food_bread", a.cutting_board}}, @@ -20,12 +22,14 @@ minetest.register_craft({ -- toast minetest.register_craftitem("farming:toast", { - description = S("Toast") .. " (♥1)", + description = S("Toast"), inventory_image = "farming_toast.png", on_use = minetest.item_eat(1), - groups = {food_toast = 1, flammable = 2, compostability = 65, eatable = 1} + groups = {food_toast = 1, compostability = 65} }) +farming.add_eatable("farming:toast", 1) + minetest.register_craft({ type = "cooking", cooktime = 3, @@ -36,12 +40,14 @@ minetest.register_craft({ -- toast sandwich minetest.register_craftitem("farming:toast_sandwich", { - description = S("Toast Sandwich") .. " (♥4)", + description = S("Toast Sandwich"), inventory_image = "farming_toast_sandwich.png", on_use = minetest.item_eat(4), - groups = {flammable = 2, compostability = 85, eatable = 4} + groups = {compostability = 85} }) +farming.add_eatable("farming:toast_sandwich", 4) + minetest.register_craft({ output = "farming:toast_sandwich", recipe = { @@ -348,12 +354,14 @@ minetest.register_craft({ -- Turkish Delight minetest.register_craftitem("farming:turkish_delight", { - description = S("Turkish Delight") .. " (♥2)", + description = S("Turkish Delight"), inventory_image = "farming_turkish_delight.png", - groups = {flammable = 3, compostability = 85, eatable = 2}, + groups = {compostability = 85}, on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:turkish_delight", 2) + minetest.register_craft({ output = "farming:turkish_delight 4", recipe = { @@ -371,12 +379,14 @@ minetest.register_craft({ -- Garlic Bread minetest.register_craftitem("farming:garlic_bread", { - description = S("Garlic Bread") .. " (♥2)", + description = S("Garlic Bread"), inventory_image = "farming_garlic_bread.png", - groups = {flammable = 3, compostability = 65, eatable = 2}, + groups = {compostability = 65}, on_use = minetest.item_eat(2) }) +farming.add_eatable("farming:garlic_bread", 2) + minetest.register_craft({ output = "farming:garlic_bread", recipe = { @@ -387,12 +397,14 @@ minetest.register_craft({ -- Donuts (thanks to Bockwurst for making the donut images) minetest.register_craftitem("farming:donut", { - description = S("Donut") .. " (♥4)", + description = S("Donut"), inventory_image = "farming_donut.png", on_use = minetest.item_eat(4), - groups = {compostability = 65, eatable = 4} + groups = {compostability = 65} }) +farming.add_eatable("farming:donut", 4) + minetest.register_craft({ output = "farming:donut 3", recipe = { @@ -403,12 +415,14 @@ minetest.register_craft({ }) minetest.register_craftitem("farming:donut_chocolate", { - description = S("Chocolate Donut") .. " (♥6)", + description = S("Chocolate Donut"), inventory_image = "farming_donut_chocolate.png", on_use = minetest.item_eat(6), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:donut_chocolate", 6) + minetest.register_craft({ output = "farming:donut_chocolate", recipe = { @@ -418,12 +432,14 @@ minetest.register_craft({ }) minetest.register_craftitem("farming:donut_apple", { - description = S("Apple Donut") .. " (♥6)", + description = S("Apple Donut"), inventory_image = "farming_donut_apple.png", on_use = minetest.item_eat(6), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:donut_apple", 6) + minetest.register_craft({ output = "farming:donut_apple", recipe = { @@ -435,12 +451,14 @@ minetest.register_craft({ -- Porridge Oats minetest.register_craftitem("farming:porridge", { - description = S("Porridge") .. " (♥6)", + description = S("Porridge"), inventory_image = "farming_porridge.png", on_use = minetest.item_eat(6, a.bowl), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:porridge", 6) + minetest.register_craft({ output = "farming:porridge", recipe = { @@ -456,12 +474,14 @@ minetest.register_craft({ -- Jaffa Cake minetest.register_craftitem("farming:jaffa_cake", { - description = S("Jaffa Cake") .. " (♥6)", + description = S("Jaffa Cake"), inventory_image = "farming_jaffa_cake.png", on_use = minetest.item_eat(6), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:jaffa_cake", 6) + minetest.register_craft({ output = "farming:jaffa_cake 3", recipe = { @@ -480,12 +500,14 @@ minetest.register_craft({ -- Apple Pie minetest.register_craftitem("farming:apple_pie", { - description = S("Apple Pie") .. " (♥6)", + description = S("Apple Pie"), inventory_image = "farming_apple_pie.png", on_use = minetest.item_eat(6), - groups = {compostability = 75, eatable = 6} + groups = {compostability = 75} }) +farming.add_eatable("farming:apple_pie", 6) + minetest.register_craft({ output = "farming:apple_pie", recipe = { @@ -498,9 +520,9 @@ minetest.register_craft({ -- Cactus Juice minetest.register_craftitem("farming:cactus_juice", { - description = S("Cactus Juice") .. " (♥1)", + description = S("Cactus Juice"), inventory_image = "farming_cactus_juice.png", - groups = {vessel = 1, drink = 1, compostability = 55, eatable = 1}, + groups = {vessel = 1, drink = 1, compostability = 55}, on_use = function(itemstack, user, pointed_thing) @@ -514,6 +536,8 @@ minetest.register_craftitem("farming:cactus_juice", { end }) +farming.add_eatable("farming:cactus_juice", 1) + minetest.register_craft({ output = "farming:cactus_juice", recipe = { @@ -556,12 +580,14 @@ minetest.register_craft({ -- Mac & Cheese minetest.register_craftitem("farming:mac_and_cheese", { - description = S("Mac & Cheese") .. " (♥6)", + description = S("Mac & Cheese"), inventory_image = "farming_mac_and_cheese.png", on_use = minetest.item_eat(6, a.bowl), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:mac_and_cheese", 6) + minetest.register_craft({ output = "farming:mac_and_cheese", recipe = { @@ -572,12 +598,14 @@ minetest.register_craft({ -- Spaghetti minetest.register_craftitem("farming:spaghetti", { - description = S("Spaghetti") .. " (♥8)", + description = S("Spaghetti"), inventory_image = "farming_spaghetti.png", on_use = minetest.item_eat(8), - groups = {compostability = 65, eatable = 8} + groups = {compostability = 65} }) +farming.add_eatable("farming:spaghetti", 8) + minetest.register_craft({ output = "farming:spaghetti", recipe = { @@ -590,12 +618,14 @@ minetest.register_craft({ -- Korean Bibimbap minetest.register_craftitem("farming:bibimbap", { - description = S("Bibimbap") .. " (♥8)", + description = S("Bibimbap"), inventory_image = "farming_bibimbap.png", on_use = minetest.item_eat(8, a.bowl), - groups = {compostability = 65, eatable = 8} + groups = {compostability = 65} }) +farming.add_eatable("farming:bibimbap", 8) + minetest.register_craft({ output = "farming:bibimbap", recipe = { @@ -620,12 +650,14 @@ minetest.register_craft({ -- Burger minetest.register_craftitem("farming:burger", { - description = S("Burger") .. " (♥16)", + description = S("Burger"), inventory_image = "farming_burger.png", on_use = minetest.item_eat(16), - groups = {compostability = 95, eatable = 16} + groups = {compostability = 95} }) +farming.add_eatable("farming:burger", 16) + minetest.register_craft({ output = "farming:burger", recipe = { @@ -638,12 +670,14 @@ minetest.register_craft({ -- Salad minetest.register_craftitem("farming:salad", { - description = S("Salad") .. " (♥8)", + description = S("Salad"), inventory_image = "farming_salad.png", on_use = minetest.item_eat(8, a.bowl), - groups = {compostability = 45, eatable = 8} + groups = {compostability = 45} }) +farming.add_eatable("farming:salad", 8) + minetest.register_craft({ output = "farming:salad", type = "shapeless", @@ -656,12 +690,14 @@ minetest.register_craft({ -- Triple Berry Smoothie minetest.register_craftitem("farming:smoothie_berry", { - description = S("Triple Berry Smoothie") .. " (♥6)", + description = S("Triple Berry Smoothie"), inventory_image = "farming_berry_smoothie.png", on_use = minetest.item_eat(6, "vessels:drinking_glass"), - groups = {vessel = 1, drink = 1, compostability = 65, eatable = 6} + groups = {vessel = 1, drink = 1, compostability = 65} }) +farming.add_eatable("farming:smoothie_berry", 6) + minetest.register_craft({ output = "farming:smoothie_berry", type = "shapeless", @@ -675,12 +711,14 @@ minetest.register_craft({ -- Patatas a la importancia minetest.register_craftitem("farming:spanish_potatoes", { - description = S("Spanish Potatoes") .. " (♥8)", + description = S("Spanish Potatoes"), inventory_image = "farming_spanish_potatoes.png", on_use = minetest.item_eat(8, a.bowl), - groups = {compostability = 65, eatable = 8} + groups = {compostability = 65} }) +farming.add_eatable("farming:spanish_potatoes", 8) + minetest.register_craft({ output = "farming:spanish_potatoes", recipe = { @@ -694,12 +732,14 @@ minetest.register_craft({ -- Potato omelet minetest.register_craftitem("farming:potato_omelet", { - description = S("Potato omelet") .. " (♥6)", + description = S("Potato omelette"), inventory_image = "farming_potato_omelet.png", on_use = minetest.item_eat(6, a.bowl), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:potato_omelet", 6) + minetest.register_craft({ output = "farming:potato_omelet", recipe = { @@ -712,12 +752,14 @@ minetest.register_craft({ -- Paella minetest.register_craftitem("farming:paella", { - description = S("Paella") .. " (♥8)", + description = S("Paella"), inventory_image = "farming_paella.png", on_use = minetest.item_eat(8, a.bowl), - groups = {compostability = 65, eatable = 8} + groups = {compostability = 65} }) +farming.add_eatable("farming:paella", 8) + minetest.register_craft({ output = "farming:paella", recipe = { @@ -731,12 +773,14 @@ minetest.register_craft({ -- Flan minetest.register_craftitem("farming:flan", { - description = S("Vanilla Flan") .. " (♥8)", + description = S("Vanilla Flan"), inventory_image = "farming_vanilla_flan.png", on_use = minetest.item_eat(6), - groups = {compostability = 65, eatable = 6} + groups = {compostability = 65} }) +farming.add_eatable("farming:flan", 6) + minetest.register_craft({ output = "farming:flan", recipe = { @@ -754,12 +798,14 @@ minetest.register_craft({ -- Vegan Cheese minetest.register_craftitem("farming:cheese_vegan", { - description = S("Vegan Cheese") .. " (♥2)", + description = S("Vegan Cheese"), inventory_image = "farming_cheese_vegan.png", on_use = minetest.item_eat(2), - groups = {compostability = 65, food_cheese = 1, flammable = 2, eatable = 2} + groups = {compostability = 65, food_cheese = 1} }) +farming.add_eatable("farming:cheese_vegan", 2) + minetest.register_craft({ output = "farming:cheese_vegan", recipe = { @@ -790,12 +836,14 @@ minetest.register_craft({ -- Onigiri minetest.register_craftitem("farming:onigiri", { - description = S("Onigiri") .. " (♥2)", + description = S("Onigiri"), inventory_image = "farming_onigiri.png", on_use = minetest.item_eat(2), - groups = {flammable = 2, compostability = 65, eatable = 2} + groups = {compostability = 65} }) +farming.add_eatable("farming:onigiri", 2) + minetest.register_craft({ output = "farming:onigiri", recipe = { @@ -807,12 +855,14 @@ minetest.register_craft({ -- Gyoza minetest.register_craftitem("farming:gyoza", { - description = S("Gyoza") .. " (♥4)", + description = S("Gyoza"), inventory_image = "farming_gyoza.png", on_use = minetest.item_eat(4), - groups = {flammable = 2, compostability = 65, eatable = 4} + groups = {compostability = 65} }) +farming.add_eatable("farming:gyoza", 4) + minetest.register_craft({ output = "farming:gyoza 4", recipe = { @@ -829,12 +879,14 @@ minetest.register_craft({ -- Mochi minetest.register_craftitem("farming:mochi", { - description = S("Mochi") .. " (♥4)", + description = S("Mochi"), inventory_image = "farming_mochi.png", on_use = minetest.item_eat(3), - groups = {flammable = 2, compostability = 65, eatable = 3} + groups = {compostability = 65} }) +farming.add_eatable("farming:mochi", 3) + minetest.register_craft({ output = "farming:mochi", recipe = { @@ -851,12 +903,14 @@ minetest.register_craft({ -- Gingerbread Man minetest.register_craftitem("farming:gingerbread_man", { - description = S("Gingerbread Man") .. " (♥2)", + description = S("Gingerbread Man"), inventory_image = "farming_gingerbread_man.png", on_use = minetest.item_eat(2), - groups = {compostability = 85, eatable = 2} + groups = {compostability = 85} }) +farming.add_eatable("farming:gingerbread_man", 2) + minetest.register_craft({ output = "farming:gingerbread_man 3", recipe = { diff --git a/init.lua b/init.lua index 1916a99..ea6a22c 100644 --- a/init.lua +++ b/init.lua @@ -7,7 +7,7 @@ farming = { mod = "redo", - version = "20240625", + version = "20240726", path = minetest.get_modpath("farming"), select = { type = "fixed", @@ -767,6 +767,27 @@ if input then input:close() end +-- helper function to add {eatable} group to food items +local mod_tt_base = minetest.get_modpath("tt_base") -- mod does similar to infotext + +function farming.add_eatable(item, hp) + + local def = minetest.registered_items[item] + + if def then + + local grps = def.groups or {} + + grps.eatable = hp ; grps.flammable = 2 + + if mod_tt_base == nil then + def.description = def.description .. " (♥" .. hp .. ")" + end + + minetest.override_item(item, {description = def.description, groups = grps}) + end +end + -- recipe items dofile(farming.path .. "/items.lua")