Merge branch 'github'

This commit is contained in:
bri cassa 2021-03-12 10:24:36 +01:00
commit a05de3929e
8 changed files with 364 additions and 288 deletions

View File

@ -10,13 +10,13 @@ food = {
modules = {},
disabled_modules = {},
debug = false,
version = 2.3,
version = 2.4,
disable_fallbacks =
minetest.setting_getbool("food.disable_fallbacks")
minetest.settings:get_bool("food.disable_fallbacks")
}
-- Checks for external content, and adds support
function food.support(group, item)
function food.support(group, item, add_it)
if type(group) == "table" then
for i = 1, #group do
food.support(group[i], item)
@ -49,8 +49,7 @@ function food.support(group, item)
return
end
food.disable(group)
if not add_it then food.disable(group) end
-- Add group
local g = {}
@ -168,9 +167,9 @@ local global_exists = minetest.global_exists or function(name)
end
-- Checks for hunger mods to register food on
function food.item_eat(amt)
function food.item_eat(amt, repl_item)
if minetest.get_modpath("diet") and global_exists("diet") and diet.item_eat then
return diet.item_eat(amt)
return diet.item_eat(amt, repl_item)
elseif minetest.get_modpath("hud") and global_exists("hud") and hud.item_eat then
return hud.item_eat(amt)
elseif minetest.get_modpath("hbhunger") then
@ -182,13 +181,14 @@ function food.item_eat(amt)
return hunger.item_eat(amt)
end
else
return minetest.item_eat(amt)
return minetest.item_eat(amt, repl_item)
end
end
-- Registers craft item or node depending on settings
function food.register(name, data, mod)
if (minetest.setting_getbool("food_use_2d") or (mod ~= nil and minetest.setting_getbool("food_"..mod.."_use_2d"))) then
if (minetest.settings:get_bool("food_use_2d")
or (mod and minetest.setting_getbool("food_"..mod.."_use_2d"))) then
minetest.register_craftitem(name,{
description = data.description,
inventory_image = data.inventory_image,

View File

@ -3,7 +3,7 @@ The Food Mod
This is the main mod in the food mod collection.
Version 2.3
Version 2.4
The Aims
--------

View File

@ -1,5 +1,6 @@
food
animalmaterials?
bucket?
bushes?
bushes_classic?
default?

View File

@ -14,22 +14,21 @@ else
S = function ( s ) return s end
end
food.module("wheat", function()
if food.bing["dry_shrub"] ~= "none" then
food.module("wheat", function()
minetest.register_craftitem(":food:wheat", {
description = S("Wheat"),
inventory_image = "food_wheat.png",
groups = {food_wheat=1}
})
food.craft({
type = "shapeless",
output = "food:wheat",
recipe = {
{"default:dry_shrub"},
}
recipe = {food.bing["dry_shrub"]}
})
end, true)
end, true)
food.module("flour", function()
food.module("flour", function()
minetest.register_craftitem(":food:flour", {
description = S("Flour"),
inventory_image = "food_flour.png",
@ -42,16 +41,11 @@ food.module("flour", function()
{"group:food_wheat"}
}
})
food.craft({
output = "food:flour",
recipe = {
{"default:sand"},
{"default:sand"}
}
})
end, true)
end, true)
end
food.module("potato", function()
if food.bing["dirt"] ~= "none" and food.bing["apple"] ~= "none" then
food.module("potato", function()
minetest.register_craftitem(":food:potato", {
description = S("Potato"),
inventory_image = "food_potato.png",
@ -60,14 +54,32 @@ food.module("potato", function()
food.craft({
output = "food:potato",
recipe = {
{"default:dirt"},
{"default:apple"}
{food.bing["dirt"]},
{food.bing["apple"]}
}
})
end, true)
end, true)
food.module("orange", function()
food.module("meat_raw", function()
minetest.register_craftitem(":food:meat_raw", {
description = S("Raw meat"),
image = "food_meat_raw.png",
on_use = food.item_eat(1),
groups = { meat=1, eatable=1, food_meat=1, food_meat_raw=1 },
stack_max=25
})
food.craft({
output = "food:meat_raw",
recipe = {
{food.bing["apple"]},
{food.bing["dirt"]}
}
})
end, true)
end
if food.bing["desert_sand"] ~= "none" then
food.module("orange", function()
minetest.register_craftitem(":food:orange", {
description = S("Orange"),
inventory_image = "food_orange.png",
@ -76,14 +88,14 @@ food.module("orange", function()
food.craft({
output = "food:orange",
recipe = {
{"", "default:desert_sand", ""},
{"default:desert_sand", "default:desert_sand", "default:desert_sand"},
{"", "default:desert_sand", ""}
{"", food.bing["desert_sand"], ""},
{food.bing["desert_sand"], food.bing["desert_sand"], food.bing["desert_sand"]},
{"", food.bing["desert_sand"], ""}
}
})
end, true)
end, true)
food.module("tomato", function()
food.module("tomato", function()
minetest.register_craftitem(":food:tomato", {
description = S("Tomato"),
inventory_image = "food_tomato.png",
@ -92,14 +104,16 @@ food.module("tomato", function()
food.craft({
output = "food:tomato",
recipe = {
{"", "default:desert_sand", ""},
{"default:desert_sand", "", "default:desert_sand"},
{"", "default:desert_sand", ""}
{"", food.bing["desert_sand"], ""},
{food.bing["desert_sand"], "", food.bing["desert_sand"]},
{"", food.bing["desert_sand"], ""}
}
})
end, true)
end, true)
end
food.module("carrot", function()
if food.bing["apple"] ~= "none" then
food.module("carrot", function()
minetest.register_craftitem(":food:carrot", {
description = S("Carrot"),
inventory_image = "food_carrot.png",
@ -109,12 +123,34 @@ food.module("carrot", function()
food.craft({
output = "food:carrot",
recipe = {
{"default:apple", "default:apple", "default:apple"},
{food.bing["apple"], food.bing["apple"], food.bing["apple"]},
}
})
end, true)
end, true)
food.module("milk", function()
food.module("cocoa", function()
minetest.register_craftitem(":food:cocoa", {
description = S("Cocoa Bean"),
inventory_image = "food_cocoa.png",
groups = {food_cocoa=1}
})
food.craft({
output = "food:cocoa",
recipe = {
{"", food.bing["apple"], ""},
{food.bing["apple"], "", food.bing["apple"]},
{"", food.bing["apple"], ""}
}
})
end, true)
end
if (food.bing["bucket_water"] ~= "none" or food.bing["bucket_river_water"] ~= "none" )
and food.bing["sand"] ~= "none" then
local repl_bucket = food.bing["bucket_empty"] ~= "none" and
{{"group:food_water_bucket", food.bing["bucket_empty"]}} or nil
food.module("milk", function()
minetest.register_craftitem(":food:milk", {
description = S("Milk"),
image = "food_milk.png",
@ -125,14 +161,16 @@ food.module("milk", function()
food.craft({
output = "food:milk",
recipe = {
{"default:sand"},
{"bucket:bucket_water"}
{"group:food_wheat"},
{"group:food_water_bucket"}
},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"}},
replacements = repl_bucket
})
end, true)
end, true)
end
food.module("egg", function()
if food.bing["sand"] ~= "none" then
food.module("egg", function()
minetest.register_craftitem(":food:egg", {
description = S("Egg"),
inventory_image = "food_egg.png",
@ -141,61 +179,16 @@ food.module("egg", function()
food.craft({
output = "food:egg",
recipe = {
{"", "default:sand", ""},
{"default:sand", "", "default:sand"},
{"", "default:sand", ""}
{"", food.bing["sand"], ""},
{food.bing["sand"], "", food.bing["sand"]},
{"", food.bing["sand"], ""}
}
})
end, true)
end, true)
end
food.module("cocoa", function()
minetest.register_craftitem(":food:cocoa", {
description = S("Cocoa Bean"),
inventory_image = "food_cocoa.png",
groups = {food_cocoa=1}
})
food.craft({
output = "food:cocoa",
recipe = {
{"", "default:apple", ""},
{"default:apple", "", "default:apple"},
{"", "default:apple", ""}
}
})
end, true)
food.module("meat", function()
minetest.register_craftitem(":food:meat", {
description = S("Venison"),
inventory_image = "food_meat.png",
groups = {food_meat=1, food_chicken=1}
})
food.craft({
type = "cooking",
output = "food:meat",
recipe = "group:food_meat_raw",
cooktime = 30
})
if not minetest.get_modpath("animalmaterials") then
minetest.register_craftitem(":food:meat_raw", {
description = S("Raw meat"),
image = "food_meat_raw.png",
on_use = food.item_eat(1),
groups = { meat=1, eatable=1, food_meat_raw=1 },
stack_max=25
})
food.craft({
output = "food:meat_raw",
recipe = {
{"default:apple"},
{"default:dirt"}
}
})
end
end, true)
food.module("sugar", function()
if food.bing["papyrus"] ~= "none" then
food.module("sugar", function()
minetest.register_craftitem(":food:sugar", {
description = S("Sugar"),
inventory_image = "food_sugar.png",
@ -203,12 +196,29 @@ food.module("sugar", function()
})
minetest.register_craft({
output = "food:sugar 20",
type = "shapeless",
output = "food:sugar",
recipe = {food.bing["papyrus"]},
})
end, true)
end
if food.bing["clay"] ~= "none" then
food.module("bowl", function()
minetest.register_craftitem(":food:bowl",{
description = S("Bowl"),
inventory_image = "food_bowl.png",
groups = {food_bowl=1}
})
food.craft({
output = "food:bowl",
recipe = {
{"default:papyrus"},
{food.bing["clay"],"",food.bing["clay"]},
{"",food.bing["clay"],""}
}
})
end, true)
end, true)
end
food.module("chocolate_powder", function()
minetest.register_craftitem(":food:chocolate_powder", {
@ -239,50 +249,25 @@ food.module("pasta", function()
})
end, true)
food.module("bowl", function()
minetest.register_craftitem(":food:bowl",{
description = S("Bowl"),
inventory_image = "food_bowl.png",
groups = {food_bowl=1}
})
food.craft({
output = "food:bowl",
recipe = {
{"default:clay_lump","","default:clay_lump"},
{"","default:clay_lump",""}
}
})
end, true)
food.module("butter", function()
minetest.register_craftitem(":food:butter", {
description = S("Butter"),
inventory_image = "food_butter.png",
groups = {food_butter=1}
})
food.craft({
output = "food:butter",
recipe = {{"group:food_milkbucket","group:food_milkbucket"}},
replacements = {
{"group:food_milkbucket","bucket:bucket_empty"},
{"group:food_milkbucket","bucket:bucket_empty"}
},
})
food.craft({
output = "food:butter",
recipe = {
{"group:food_milk","group:food_milkbucket"}
},
replacements = {
{"group:food_milkbucket","bucket:bucket_empty"},
},
})
food.craft({
output = "food:butter",
recipe = {
{"group:food_milk","group:food_milk"},
}
})
local replacements = food.bing["bucket_empty"] ~= "none" and {{"group:food_milkbucket", food.bing["bucket_empty"].." 2"}}
or nil
food.craft({
output = "food:butter 2",
recipe = {{"group:food_milkbucket","group:food_milkbucket"}},
replacements = replacements
})
end, true)
food.module("cheese", function()
@ -299,12 +284,3 @@ food.module("cheese", function()
}
})
end, true)
if (minetest.get_modpath("animalmaterials") and not minetest.get_modpath("mobfcooking")) then
food.craft({
type = "cooking",
output = "food:meat",
recipe = "animalmaterials:meat_raw",
cooktime = 30
})
end

View File

@ -6,8 +6,9 @@
-- Some basic foods
-- =====================================
print("Food Mod - Version 2.3")
print("Food Mod - Version 2.4")
dofile(minetest.get_modpath("food_basic").."/settings.lua")
dofile(minetest.get_modpath("food_basic").."/support.lua")
dofile(minetest.get_modpath("food_basic").."/ingredients.lua")
@ -19,6 +20,21 @@ else
S = function ( s ) return s end
end
-- Register Venison
food.module("meat_cooked", function()
minetest.register_craftitem(":food:meat", {
description = S("Venison"),
inventory_image = "food_meat.png",
groups = {food_meat=1, food_meat_cooked=1}
})
food.craft({
type = "cooking",
output = "food:meat",
recipe = "group:food_meat_raw",
cooktime = 30
})
end)
-- Register dark chocolate
food.module("dark_chocolate", function()
minetest.register_craftitem(":food:dark_chocolate",{
@ -48,7 +64,10 @@ food.module("milk_chocolate", function()
recipe = {
{"","group:food_milk",""},
{"group:food_cocoa","group:food_cocoa","group:food_cocoa"}
}
},
replacements = {{"mobs:bucket_milk", "bucket:bucket_empty"},
{"mobs:glass_milk", "vessels:drinking_glass"},
{"farming:soy_milk", "vessels:drinking_glass"}}
})
end)
@ -89,19 +108,17 @@ food.module("pasta_bake", function()
{"group:food_cheese"},
{"group:food_pasta"},
{"group:food_bowl"}
}
},
})
end)
-- Register Soups
local chicken = "meat"
if minetest.get_modpath("mobs") and mobs.mod == "redo" then
chicken = "chicken"
end
local soups = {
{"tomato", "tomato"},
{"chicken", chicken}
{"chicken", "meat_raw"}
}
local repl_bucket = food.bing["bucket_empty"] ~= "none" and
{{"group:food_water_bucket", food.bing["bucket_empty"].." 2"}} or nil
for i=1, #soups do
local flav = soups[i]
food.module("soup_"..flav[1], function()
@ -114,7 +131,6 @@ for i=1, #soups do
minetest.register_craftitem(":food:soup_"..flav[1].."_raw",{
description = S("Uncooked ".. flav[1].." Soup"),
inventory_image = "food_soup_"..flav[1].."_raw.png",
})
food.craft({
type = "cooking",
@ -125,10 +141,10 @@ for i=1, #soups do
output = "food:soup_"..flav[1].."_raw",
recipe = {
{"", "", ""},
{"bucket:bucket_water", "group:food_"..flav[2], "bucket:bucket_water"},
{"group:food_water_bucket", "group:food_"..flav[2], "group:food_water_bucket"},
{"", "group:food_bowl", ""},
},
replacements = {{"bucket:bucket_water", "bucket:bucket_empty"},{"bucket:bucket_water", "bucket:bucket_empty"}}
replacements = repl_bucket
})
end)
end
@ -141,14 +157,15 @@ for i=1, #juices do
minetest.register_craftitem(":food:"..flav.."_juice", {
description = S(flav.." Juice"),
inventory_image = "food_"..flav.."_juice.png",
on_use = food.item_eat(2),
on_use = food.item_eat(2, food.bing["cup"]),
groups = {["food_"..flav.."_juice"] = 1, vessel = 1}
})
food.craft({
output = "food:"..flav.."_juice 4",
output = "food:"..flav.."_juice",
recipe = {
{"","",""},
{"","group:food_"..flav,""},
{"","group:food_cup",""},
{"",food.bing["cup"],""},
}
})
end)
@ -158,15 +175,26 @@ food.module("rainbow_juice", function()
minetest.register_craftitem(":food:rainbow_juice", {
description = S("Rainbow Juice"),
inventory_image = "food_rainbow_juice.png",
on_use = food.item_eat(20),
on_use = food.item_eat(20, food.bing["cup"]),
groups = { vessel = 1 }
})
if minetest.registered_items["default:nyancat_rainbow"] then
food.craft({
output = "food:rainbow_juice 99",
recipe = {
{"","",""},
{"","default:nyancat_rainbow",""},
{"","group:food_cup",""},
{"",food.bing["cup"],""},
}
})
end
food.craft({
output = "food:rainbow_juice 3",
recipe = {
{"group:food_apple_juice","group:food_apple_juice","group:food_apple_juice"},
{"group:food_orange_juice","group:food_orange_juice","group:food_orange_juice"},
{"group:food_cactus_juice","group:food_cactus_juice","group:food_cactus_juice"}
}
})
end)

16
food_basic/settings.lua Normal file
View File

@ -0,0 +1,16 @@
food.bing = {} -- List of basic ingredients defined from Minetest settings
local settings = minetest.settings
food.bing["desert_sand"] = settings:get("basic_food_desert_sand") or "default:desert_sand"
food.bing["sand"] = settings:get("basic_food_sand") or "default:sand"
food.bing["dry_shrub"] = settings:get("basic_food_dry_shrub") or "default:dry_shrub"
food.bing["dirt"] = settings:get("basic_food_dirt") or "default:dirt"
food.bing["apple"] = settings:get("basic_food_apple") or "default:apple"
food.bing["cactus"] = settings:get("basic_food_cactus") or "default:cactus"
food.bing["bucket_water"] = settings:get("basic_food_bucket_water") or "bucket:bucket_water"
food.bing["bucket_river_water"] = settings:get("basic_food_bucket_river_water") or "bucket:bucket_river_water"
food.bing["bucket_empty"] = settings:get("basic_food_bucket_empty") or "bucket:bucket_empty"
food.bing["papyrus"] = settings:get("basic_food_papyrus") or "default:papyrus"
food.bing["clay"] = settings:get("basic_food_clay") or "default:clay_lump"
food.bing["cup"] = settings:get("basic_food_cup") or "vessels:drinking_glass"

View File

@ -0,0 +1,49 @@
[Basic Ingredients]
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:dirt".
# If you want disable this ingredient you must write "none".
basic_food_dirt (Ingredient for potato, raw meat) string default:dirt
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:sand".
# If you want disable this ingredient you must write "none".
basic_food_sand (Ingredient for egg) string default:sand
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:desert_sand".
# If you want disable this ingredient you must write "none".
basic_food_desert_sand (Ingredient for orange, tomato) string default:desert_sand
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:apple".
# If you want disable this ingredient you must write "none".
basic_food_apple (Ingredient for potato, cocoa bean, raw meat, carrot, apple juice) string default:apple
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:cactus".
# If you want disable this ingredient you must write "none".
basic_food_cactus (Ingredient for cactus juice) string default:cactus
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:dry_shrub".
# If you want disable this ingredient you must write "none".
basic_food_dry_shrub (Ingredient for wheat) string default:dry_shrub
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "bucket:bucket_water".
# If you want disable this ingredient you must write "none".
basic_food_bucket_water (Ingredient for milk, tomato soup, chicken soup) string bucket:bucket_water
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "bucket:bucket_river_water".
# If you want disable this ingredient you must write "none".
basic_food_bucket_river_water (In the same group as basic_food_bucket_water) string bucket:bucket_river_water
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "bucket:bucket_empty".
# If you want disable this ingredient you must write "none".
basic_food_bucket_empty (Item replacement when cooking with the above two ingredients) string bucket:bucket_empty
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:papyrus".
# If you want disable this ingredient you must write "none".
basic_food_papyrus (Ingredient for sugar) string default:papyrus
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "default:clay_lump".
# If you want disable this ingredient you must write "none".
basic_food_clay (Ingredient for bowl) string default:clay_lump
# Basic ingredient you may use instead of the default one defined by the mod.
# Default is "vessels:drinking_glass".
# If you want disable this ingredient you must write "none".
basic_food_cup (Ingredient for apple|orange|cactus juice) string vessels:drinking_glass

View File

@ -12,35 +12,52 @@
-- good for the end user
-- Add support for other mods
food.support("cocoa", "farming_plus:cocoa_bean")
food.support("cup", "vessels:drinking_glass")
food.support("cactus", "default:cactus")
food.support("apple", "default:apple")
food.support("flour", {
"farming:flour",
"farming:flour_multigrain",
})
food.support("wheat", "farming:wheat")
food.support("bowl", "farming:bowl")
food.support("cocoa", {"farming_plus:cocoa_bean", "farming:cocoa_beans"})
food.support("cup", food.bing["cup"])
food.support("cactus", food.bing["cactus"])
food.support("apple", food.bing["apple"])
food.support("orange", {
"farming_plus:orange_item",
"ethereal:orange",
"ethereal:orange"
})
food.disable_if("ethereal", "orange")
food.support("potato", {
"docfarming:potato",
"veggies:potato",
"farming_plus:potato_item"
"farming_plus:potato_item",
"farming:potato"
})
food.support("tomato", {
"farming_plus:tomato_item",
"plantlib:tomato"
"plantlib:tomato",
"farming:tomato"
})
food.support("carrot", {
"farming_plus:carrot_item",
"docfarming:carrot",
"plantlib:carrot",
"jkfarming:carrot"
"jkfarming:carrot",
"farming:carrot"
})
food.support("milk", {
"animalmaterials:milk",
"my_mobs:milk_glass_cup",
"mtfoods:dandelion_milk"
"mtfoods:dandelion_milk",
"mobs:glass_milk",
"farming:soy_milk"
})
food.support("butter", "mobs:butter")
food.support("cheese", "mobs:cheese")
food.support("water_bucket", {
food.bing["bucket_water"],
food.bing["bucket_river_water"]
})
food.support("milkbucket", {
"jkanimals:bucket_milk",
@ -52,42 +69,31 @@ food.support("egg", {
"jkanimals:egg",
"mobs:egg"
})
food.support("meat", {
food.support("meat_cooked", {
"mobs:meat",
"jkanimals:meat",
"mobfcooking:cooked_pork",
"mobfcooking:cooked_beef",
"mobfcooking:cooked_chicken",
"mobfcooking:cooked_lamb",
"mobfcooking:cooked_venison"
"mobfcooking:cooked_venison",
"farming:tofu_cooked"
})
food.support("meat_raw", {
"mobs:meat_raw",
"mobs:chicken_raw",
"farming:tofu"
})
food.support("sugar", {
"jkfarming:sugar",
"bushes:sugar",
"mtfoods:sugar"
"mtfoods:sugar",
"mobs:honey",
"farming:sugar"
})
if farming and farming.mod == "redo" then
food.support("wheat", "farming:wheat")
food.support("flour", "farming:flour")
food.support("carrot", "farming:carrot")
food.support("potato", "farming:potato")
food.support("tomato", "farming:tomato")
food.support("cocoa", "farming:cocoa_beans")
food.support("coffee", "farming:coffee_beans")
food.support("dark_chocolate", "farming:chocolate_dark")
food.support("sugar", "farming:sugar")
food.support("cup", "farming:drinking_cup")
food.disable_if("farming", "baked_potato")
else
food.support("wheat", "farming:wheat")
food.support("flour", "farming:flour")
end
if minetest.get_modpath("mobs") and mobs.mod == "redo" then
if minetest.get_modpath("mobs_animal") then
food.support("chicken", "mobs:chicken_cooked")
else
food.support("chicken", "mobs:meat")
end
end
food.support("cactus_juice", "farming:cactus_juice")
food.support("orange_juice", "farming:carrot_juice", true)
food.support("apple_juice", "farming:pineapple_juice", true)
food.support("dark_chocolate", "farming:chocolate_dark")
food.support("baked_potato", "farming:baked_potato")
food.support("pasta", "farming:pasta")