Difference between revisions of "Nutrition"

From Pandorabox
Jump to navigation Jump to search
Line 373: Line 373:
 
inventory_image = "default_gold_block.png",
 
inventory_image = "default_gold_block.png",
 
on_use = function(itemstack, user, pointed_thing)
 
on_use = function(itemstack, user, pointed_thing)
local items = {}
+
local additional_info = {
 +
["maptools:superapple"] = " Not obtainable (/giveme only)",
 +
["farming:jaffa_cake"] = " Requires rare food to craft (Orange)",
 +
["farming:smoothie_berry"] = " Requires rare food to craft (Strawberry and Banana)",
 +
["ethereal:orange"] = " Rare food (obtainable from dungeons)",
 +
["ethereal:banana"] = " Rare food (obtainable from Christmas presents)",
 +
["default:blueberries"] = " Not to be confused with `farming:blueberries`",
 +
["farming:blueberries"] = " Not to be confused with `default:blueberries`",
 +
["ethereal:strawberry"] = " Rare food (obtainable from dungeons)",
 +
}
 +
local chance_dependant = {
 +
["farming:cactus_juice"] = true,
 +
["farming:potato"] = true,
 +
}
 +
local items = {
 +
"| -1 || Cactus Juice || farming:cactus_juice || 1/5 chance (4/5 chance to not poison)\n|-",
 +
"| 2 || Cactus Juice || farming:cactus_juice || 4/5 chance (1/5 chance to poison)\n|-",
 +
"| -1 || Potato || farming:potato || 1/3 chance (2/3 chance to not poison)\n|-",
 +
"| 1 || Potato || farming:potato || 2/3 chance (1/3 chance to poison)\n|-",
 +
}
 
-- Override do_item_eat function
 
-- Override do_item_eat function
 
local old_do_eat = minetest.do_item_eat
 
local old_do_eat = minetest.do_item_eat
Line 379: Line 398:
 
local item = itemstack:get_name()
 
local item = itemstack:get_name()
 
local desc = minetest.registered_items[item].description or ""
 
local desc = minetest.registered_items[item].description or ""
if desc ~= "" then
+
local info = additional_info[item] or ""
desc = minetest.get_translated_string("", desc) .. " "
+
if not chance_dependant[item] then
 +
if desc ~= "" then
 +
desc = minetest.get_translated_string("", desc) .. " "
 +
end
 +
items[#items+1] = "| " .. hp_change .. " || " .. desc .. "|| "
 +
.. item .. " ||" .. info .. "\n|-"
 
end
 
end
items[#items+1] = hp_change .. " " .. desc .. item
 
 
end
 
end
 
-- Run on_use callback for all registered items
 
-- Run on_use callback for all registered items
Line 392: Line 415:
 
-- Sort items by nutrition value, then by name
 
-- Sort items by nutrition value, then by name
 
table.sort(items, function(a, b)
 
table.sort(items, function(a, b)
local na = tonumber(a:split(" ")[1])
+
local na = tonumber(a:split(" ")[2])
local nb = tonumber(b:split(" ")[1])
+
local nb = tonumber(b:split(" ")[2])
 
if na ~= nb then
 
if na ~= nb then
 
return nb < na
 
return nb < na

Revision as of 12:47, 27 January 2022

About nutrition and stamina

Nutrition refers to how much a food can feed or poison a player, and stamina refers to the value stored in the player, as displayed on the HUD. These terms can also be known as hunger points, food points, stamina points, hunger, or bread.

A positive nutrition value feeds the player, while a negative value poisons the player. The maximum usable nutrition is 20, and the minimum is -20 (poison), anything outside of this range is wasted (for example, Date-nut cake will only give a maximum of 20 stamina, even though it has 32 nutrition).

The stamina HUD (row of bread icons) displays 20 half-loaves of bread (10 full loafs). To calculate how many bread icons are filled up on the HUD when eating an item, divide the nutrition by 2.

Full list of foods

Nutrition Name Itemstring Comment
32 Date-nut cake moretrees:date_nut_cake
30 Marinated tomatoes canned_food:canned_tomato_plus
30 Pickled carrot sticks canned_food:canned_carrot_plus
30 Pickles canned_food:canned_cucumber_plus
21 A jar of honey canned_food:honey_jar
20 Meat Block mobs:meatblock
20 Super Apple maptools:superapple Not obtainable (/giveme only)
16 Burger farming:burger
15 Canned carrots canned_food:canned_carrot
15 Canned cucumbers canned_food:canned_cucumber
15 Canned tomatoes canned_food:canned_tomato
15 Wild blueberry jam canned_food:wild_blueberry_jam
14 Pickled chili pepper canned_food:canned_chili_pepper_plus
12 Mexican pickled potatoes canned_food:canned_potato_plus
12 Pickled beetroot canned_food:canned_beetroot_plus
12 Salted mushrooms canned_food:canned_mushrooms_plus
11 Canned corn canned_food:canned_corn
11 Grape jam canned_food:grape_jam
10 Canned peas canned_food:canned_peas
10 Cucumber and Potato Salad farming:potato_salad
10 Golden Carrot farming:carrot_gold
10 Pickled garlic cloves canned_food:canned_garlic_cloves_plus
10 Pickled onions canned_food:canned_onion_plus
8 Bibimbap farming:bibimbap
8 Blackberry jam canned_food:blackberry_jam
8 Blueberry jam canned_food:blueberry_jam
8 Bowl of Chili farming:chili_bowl
8 Bucket of Milk mobs:bucket_milk
8 Cooked Porkchop mobs:pork_cooked
8 Meat mobs:meat
8 Melon jam canned_food:melon_jam
8 Paella farming:paella
8 Pumpkin Bread farming:pumpkin_bread
8 Raspberry jam canned_food:raspberry_jam
8 Rhubarb jam canned_food:rhubarb_jam
8 Salad farming:salad
8 Spaghetti farming:spaghetti
8 Spanish Potatoes farming:spanish_potatoes
8 Sunflower Seed Bread farming:sunflower_bread
8 Tomato Soup farming:tomato_soup
7 Apple jam canned_food:apple_jam
7 Canned beans canned_food:canned_beans
7 Canned chili pepper canned_food:canned_chili_pepper
7 Canned pumpkin puree canned_food:canned_pumpkin
7 Multigrain Bread farming:bread_multigrain
6 Apple Donut farming:donut_apple
6 Apple Pie farming:apple_pie
6 Baked Potato farming:baked_potato
6 Beetroot Soup farming:beetroot_soup
6 Blueberry Pie farming:blueberry_pie
6 Canned beetroot canned_food:canned_beetroot
6 Canned mushrooms canned_food:canned_mushrooms
6 Canned pineapple rings canned_food:canned_pineapple
6 Canned potatoes canned_food:canned_potato
6 Chocolate Donut farming:donut_chocolate
6 Cooked Chicken mobs:chicken_cooked
6 Cooked Mutton mobs:mutton_cooked
6 Cooked Tofu farming:tofu_cooked
6 Dandelion jam canned_food:dandelion_jam
6 Jaffa Cake farming:jaffa_cake Requires rare food to craft (Orange)
6 Onion Soup farming:onion_soup
6 Porridge farming:porridge
6 Potato omelet farming:potato_omelet
6 Rhubarb Pie farming:rhubarb_pie
6 Rose petal jam canned_food:rose_jam
6 Triple Berry Smoothie farming:smoothie_berry Requires rare food to craft (Strawberry and Banana)
6 Vanilla Flan farming:flan
5 Bread farming:bread
5 Canned garlic cloves canned_food:canned_garlic_cloves
5 Canned onions canned_food:canned_onion
5 Cooked Rabbit mobs:rabbit_cooked
5 Corn on the Cob farming:corn_cob
5 Rice Bread farming:rice_bread
4 Acorn Muffin moretrees:acorn_muffin
4 Artichoke farming:artichoke
4 Carrot Juice farming:carrot_juice
4 Carrot farming:carrot
4 Cheese mobs:cheese
4 Cucumber farming:cucumber
4 Date & nut snack moretrees:date_nut_snack
4 Date-nut energy bar moretrees:date_nut_bar
4 Donut farming:donut
4 Glass of Champagne wine:glass_champagne
4 Glass of Honey-Mead wine:glass_mead
4 Glass of Mint Julep wine:glass_mint
4 Gyoza farming:gyoza
4 Honey mobs:honey
4 Orange ethereal:orange Rare food (obtainable from dungeons)
4 Pea Soup farming:pea_soup
4 Pineapple Juice farming:pineapple_juice
4 Popcorn farming:popcorn
4 Raw Coconut moretrees:raw_coconut
4 Raw Porkchop mobs:pork_raw
4 Red Pepper farming:pepper_red
4 Toast Sandwich farming:toast_sandwich
4 Tomato farming:tomato
3 Bar of Dark Chocolate farming:chocolate_dark
3 Cooked Rat mobs:rat_cooked
3 Corn farming:corn
3 Glass of Brandy wine:glass_brandy
3 Glass of Coffee Liquor wine:glass_coffee_liquor
3 Mochi farming:mochi
3 Raw Meat mobs:meat_raw
3 Raw Rabbit mobs:rabbit_raw
3 Tofu farming:tofu
3 Yellow Pepper farming:pepper_yellow
2 Apple default:apple
2 Bamboo Sprout bamboo:sprout
2 Banana ethereal:banana Rare food (obtainable from Christmas presents)
2 Beer mug home_workshop_misc:beer_mug
2 Blue Agave wine:blue_agave
2 Blueberries default:blueberries Not to be confused with `farming:blueberries`
2 Blueberry Muffin farming:muffin_blueberry
2 Cactus Juice farming:cactus_juice 4/5 chance (1/5 chance to poison)
2 Cherries cherrytree:cherries
2 Chili Pepper farming:chili_pepper
2 Coconut Milk moretrees:coconut_milk
2 Cookie farming:cookie
2 Cup of Coffee farming:coffee_cup
2 Fried Egg mobs:chicken_egg_fried
2 Garlic Bread farming:garlic_bread
2 Glass of Beer wine:glass_beer
2 Glass of Bourbon wine:glass_bourbon
2 Glass of Cider wine:glass_cider
2 Glass of Milk mobs:glass_milk
2 Glass of Rum wine:glass_rum
2 Glass of Sake wine:glass_sake
2 Glass of Tequila wine:glass_tequila
2 Glass of Vodka wine:glass_vodka
2 Glass of Wheat Beer wine:glass_wheat_beer
2 Glass of Wine wine:glass_wine
2 Grapes farming:grapes
2 Green Pepper farming:pepper
2 Lettuce farming:lettuce
2 Melon Slice farming:melon_slice
2 Mint Tea farming:mint_tea
2 Onirigi farming:onigiri
2 Pumpkin Slice farming:pumpkin_slice
2 Raspberry Smoothie farming:smoothie_raspberry
2 Raw Chicken mobs:chicken_raw
2 Raw Mutton mobs:mutton_raw
2 Soy Milk farming:soy_milk
2 Turkish Delight farming:turkish_delight
2 Vegan Cheese farming:cheese_vegan
1 Beetroot farming:beetroot
1 Blackberries farming:blackberry
1 Blueberries farming:blueberries Not to be confused with `default:blueberries`
1 Brown Mushroom flowers:mushroom_brown
1 Butter mobs:butter
1 Cabbage farming:cabbage
1 Date moretrees:date
1 Garlic farming:garlic
1 Green Beans farming:beans
1 Onion farming:onion
1 Peas farming:peas
1 Pineapple Ring farming:pineapple_ring
1 Potato farming:potato 2/3 chance (1/3 chance to poison)
1 Raspberries farming:raspberries
1 Rhubarb farming:rhubarb
1 Roasted Cedar Cone Nuts moretrees:cedar_nuts
1 Roasted Fir Cone Nuts moretrees:fir_nuts
1 Roasted Spruce Cone Nuts moretrees:spruce_nuts
1 Sliced Bread farming:bread_slice
1 Soy Beans farming:soy_beans
1 Strawberry ethereal:strawberry Rare food (obtainable from dungeons)
1 Toast farming:toast
1 Toasted Sunflower Seeds farming:sunflower_seeds_toasted
1 Vanilla farming:vanilla
-1 Cactus Juice farming:cactus_juice 1/5 chance (4/5 chance to not poison)
-1 Potato farming:potato 1/3 chance (2/3 chance to not poison)
-5 Red Mushroom flowers:mushroom_red

How this list was created

The information in the above list was gathered by adding a testing tool using the code below. The testing tool was then used in a world containing every mod that is used on Pandorabox, including the default mods in Minetest Game.

For Cactus Juice and Potato, the data was extracted from the mod code manually.

local test_food = "test:food_test"
minetest.register_craftitem(test_food, {
	description = "Food Nutrition Tester",
	inventory_image = "default_gold_block.png",
	on_use = function(itemstack, user, pointed_thing)
		local additional_info = {
			["maptools:superapple"] = " Not obtainable (/giveme only)",
			["farming:jaffa_cake"] = " Requires rare food to craft (Orange)",
			["farming:smoothie_berry"] = " Requires rare food to craft (Strawberry and Banana)",
			["ethereal:orange"] = " Rare food (obtainable from dungeons)",
			["ethereal:banana"] = " Rare food (obtainable from Christmas presents)",
			["default:blueberries"] = " Not to be confused with `farming:blueberries`",
			["farming:blueberries"] = " Not to be confused with `default:blueberries`",
			["ethereal:strawberry"] = " Rare food (obtainable from dungeons)",
		}
		local chance_dependant = {
			["farming:cactus_juice"] = true,
			["farming:potato"] = true,
		}
		local items = {
			"| -1 || Cactus Juice || farming:cactus_juice || 1/5 chance (4/5 chance to not poison)\n|-",
			"| 2 || Cactus Juice || farming:cactus_juice || 4/5 chance (1/5 chance to poison)\n|-",
			"| -1 || Potato || farming:potato || 1/3 chance (2/3 chance to not poison)\n|-",
			"| 1 || Potato || farming:potato || 2/3 chance (1/3 chance to poison)\n|-",
		}
		-- Override do_item_eat function
		local old_do_eat = minetest.do_item_eat
		minetest.do_item_eat = function(hp_change, replace_with_item, itemstack, player, pointed_thing)
			local item = itemstack:get_name()
			local desc = minetest.registered_items[item].description or ""
			local info = additional_info[item] or ""
			if not chance_dependant[item] then
				if desc ~= "" then
					desc = minetest.get_translated_string("", desc) .. " "
				end
				items[#items+1] = "| " .. hp_change .. " || " .. desc .. "|| "
								.. item .. " ||" .. info .. "\n|-"
			end
		end
		-- Run on_use callback for all registered items
		for k,v in pairs(minetest.registered_items) do
			if k ~= test_food and type(v.on_use) == "function" then
				v.on_use(ItemStack(k), user, pointed_thing)
			end
		end
		-- Sort items by nutrition value, then by name
		table.sort(items, function(a, b)
			local na = tonumber(a:split(" ")[2])
			local nb = tonumber(b:split(" ")[2])
			if na ~= nb then
				return nb < na
			end
			return a < b
		end)
		-- Output results
		for _,v in ipairs(items) do
			print(v)
		end
		-- Undo override
		minetest.do_item_eat = old_do_eat
	end
})