generated from your-land/yl_template
Fixes additives nil and formatting
This commit is contained in:
parent
28d53ff0f2
commit
d27ea86306
@ -1,11 +1,8 @@
|
||||
-- item eat integration
|
||||
|
||||
if (yl_canned_food_mtg.settings.enable_eat ~= true) then
|
||||
return false
|
||||
end
|
||||
if (yl_canned_food_mtg.settings.enable_eat ~= true) then return false end
|
||||
|
||||
-- dependencies
|
||||
if (minetest.get_modpath("vessels") == nil) then
|
||||
if (minetest.get_modpath("vessels") == nil) then
|
||||
yl_canned_food_mtg.log("feature item_eat enabled, but mod vessels not found")
|
||||
return false
|
||||
end
|
||||
@ -22,7 +19,7 @@ for _, recipe in ipairs(yl_canned_food_mtg.recipes) do
|
||||
|
||||
-- pickled
|
||||
local redefinition_plus = {
|
||||
on_use = minetest.item_eat(recipe.nutrition*2, "vessels:glass_bottle")
|
||||
on_use = minetest.item_eat(recipe.nutrition * 2, "vessels:glass_bottle")
|
||||
}
|
||||
minetest.override_item(recipe.out .. "_plus", redefinition_plus)
|
||||
|
||||
|
@ -1,14 +1,11 @@
|
||||
-- recipes integration
|
||||
|
||||
if (yl_canned_food_mtg.settings.enable_recipes ~= true) then return false end
|
||||
|
||||
local amount = 0
|
||||
|
||||
local function group_has_member(group)
|
||||
for itemname, _ in pairs(minetest.registered_items) do
|
||||
if minetest.get_item_group(itemname, group) ~= 0 then
|
||||
return true
|
||||
end
|
||||
if minetest.get_item_group(itemname, group) ~= 0 then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -25,19 +22,16 @@ for _, recipe in ipairs(yl_canned_food_mtg.recipes) do
|
||||
local ingredient = recipe.base_mod .. ":" .. recipe.base_item
|
||||
itemcache[ingredient] = true
|
||||
|
||||
for _, additive in ipairs(recipe.additives) do
|
||||
itemcache[additive] = true
|
||||
end
|
||||
for _, additive in ipairs(recipe.additives) do itemcache[additive] = true end
|
||||
end
|
||||
|
||||
local item_good = {}
|
||||
|
||||
for item,_ in pairs(itemcache) do
|
||||
for item, _ in pairs(itemcache) do
|
||||
local groupname = item:match("^group:(.*)")
|
||||
if (groupname == nil) then
|
||||
item_good[item] = (minetest.registered_items[item] ~= nil)
|
||||
else
|
||||
core.log("action","groupname="..dump(groupname))
|
||||
item_good[item] = group_has_member(groupname)
|
||||
end
|
||||
end
|
||||
@ -45,20 +39,38 @@ end
|
||||
for _, recipe in ipairs(yl_canned_food_mtg.recipes) do
|
||||
|
||||
local crafting = {}
|
||||
local success = true
|
||||
|
||||
-- vessel
|
||||
table.insert(crafting, vessel)
|
||||
if (item_good[vessel] ~= false) then
|
||||
success = success and true
|
||||
else
|
||||
success = false
|
||||
end
|
||||
|
||||
-- additive
|
||||
for _, additive in ipairs(recipe.additives) do
|
||||
table.insert(crafting, additive)
|
||||
if (item_good[additive] ~= false) then
|
||||
success = success and true
|
||||
else
|
||||
success = false
|
||||
end
|
||||
end
|
||||
-- ingredient
|
||||
local ingredient = recipe.base_mod .. ":" .. recipe.base_item
|
||||
|
||||
for i = recipe.base_amount, 1, -1 do
|
||||
table.insert(crafting, ingredient)
|
||||
if (item_good[ingredient] ~= false) then
|
||||
success = success and true
|
||||
else
|
||||
success = false
|
||||
end
|
||||
end
|
||||
|
||||
if (item_good[vessel] ~= false) and (item_good[additive] ~= false) and (item_good[ingredient] ~= false) then
|
||||
|
||||
if (success == true) then
|
||||
-- register the craft
|
||||
minetest.register_craft({
|
||||
output = recipe.out,
|
||||
@ -67,6 +79,9 @@ for _, recipe in ipairs(yl_canned_food_mtg.recipes) do
|
||||
})
|
||||
|
||||
amount = amount + 1
|
||||
else
|
||||
minetest.log("warning",
|
||||
yl_canned_food_mtg.t("recipe_not_good", recipe.out))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,17 +1,19 @@
|
||||
-- unified_inventory integration
|
||||
|
||||
if (yl_canned_food_mtg.settings.enable_unified_inventory ~= true) then
|
||||
return false
|
||||
end
|
||||
|
||||
-- dependencies
|
||||
if (minetest.get_modpath("unified_inventory") == nil) then
|
||||
yl_canned_food_mtg.log("feature unfied_inventory enabled, but mod unfied_inventory not found")
|
||||
if (minetest.get_modpath("unified_inventory") == nil) then
|
||||
yl_canned_food_mtg.log(
|
||||
"feature unfied_inventory enabled, but mod unfied_inventory not found")
|
||||
return false
|
||||
end
|
||||
|
||||
assert((type(unified_inventory.register_craft_type) == "function"), "register_craft_type does not exist in unified_inventory")
|
||||
assert((type(unified_inventory.register_craft) == "function"), "register_craft does not exist in unified_inventory")
|
||||
assert((type(unified_inventory.register_craft_type) == "function"),
|
||||
"register_craft_type does not exist in unified_inventory")
|
||||
assert((type(unified_inventory.register_craft) == "function"),
|
||||
"register_craft does not exist in unified_inventory")
|
||||
|
||||
unified_inventory.register_craft_type("yl_canned_food", {
|
||||
description = yl_canned_food_mtg.t(
|
||||
|
Loading…
Reference in New Issue
Block a user