From b150d227e1e5fb99a2442eddca98a817abf18909 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 16 Jan 2017 14:29:41 +0100 Subject: [PATCH] Clean up creative inventory tabs a little --- API.md | 8 ++++++++ mods/cake/init.lua | 12 ++++++------ mods/craftingpack/crafting/creative.lua | 4 ++-- mods/default/craftitems.lua | 2 ++ mods/farming/carrots.lua | 2 ++ mods/farming/melon.lua | 1 + mods/farming/mushrooms.lua | 1 + mods/farming/potatoes.lua | 3 +++ mods/farming/wheat.lua | 4 ++-- mods/mobs/item.lua | 14 ++++++++++++++ mods/throwing/arrow.lua | 1 + mods/throwing/init.lua | 1 + 12 files changed, 43 insertions(+), 10 deletions(-) diff --git a/API.md b/API.md index fadd8a045d..f1260b29d4 100644 --- a/API.md +++ b/API.md @@ -16,6 +16,14 @@ This section explains all the used groups in this subgame. * `soil_sapling=1`: Artificial soil (such as farmland) for saplings. Some saplings will not grow on this * `soil_sugarcane=1`: Sugar canes will grow on this near water * `disable_suffocation=1`: Disables suffocation for full solid cubes (1) +* `food`: Item is a comestible item which can be consumed (healthy or unhealthy) + * `food=2`: Food + * `food=3`: Drink + * `food=1`: Other/unsure +* `eatable`: Item can be *directly* eaten by wielding + left click (`on_use=item_eat`). Rating is the satiation gain +* `ammo=1`: Item is used as ammo for a weapon +* `ammo_bow=1`: Item is used as ammo for bows +* `weapon_ranged=1`: Item is a ranged weapon ### Footnotes diff --git a/mods/cake/init.lua b/mods/cake/init.lua index 53c14a0362..8bc2b22f13 100644 --- a/mods/cake/init.lua +++ b/mods/cake/init.lua @@ -37,7 +37,7 @@ minetest.register_node("cake:cake", { fixed = slice_6 }, stack_max = 1, - groups = {crumbly=3,falling_node=1}, + groups = {food=2,crumbly=3,falling_node=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then @@ -60,7 +60,7 @@ minetest.register_node("cake:cake_5", { type = "fixed", fixed = slice_5 }, - groups = {crumbly=3,falling_node=1,not_in_creative_inventory=1}, + groups = {food=2,crumbly=3,falling_node=1,not_in_creative_inventory=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then @@ -83,7 +83,7 @@ minetest.register_node("cake:cake_4", { type = "fixed", fixed = slice_4 }, - groups = {crumbly=3,falling_node=1,not_in_creative_inventory=1}, + groups = {food=2,crumbly=3,falling_node=1,not_in_creative_inventory=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then @@ -106,7 +106,7 @@ minetest.register_node("cake:cake_3", { type = "fixed", fixed = slice_3 }, - groups = {crumbly=3,falling_node=1,not_in_creative_inventory=1}, + groups = {food=2,crumbly=3,falling_node=1,not_in_creative_inventory=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then @@ -129,7 +129,7 @@ minetest.register_node("cake:cake_2", { type = "fixed", fixed = slice_2 }, - groups = {crumbly=3,falling_node=1,not_in_creative_inventory=1}, + groups = {food=2,crumbly=3,falling_node=1,not_in_creative_inventory=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then @@ -152,7 +152,7 @@ minetest.register_node("cake:cake_1", { type = "fixed", fixed = slice_1 }, - groups = {crumbly=3,falling_node=1,not_in_creative_inventory=1}, + groups = {food=2,crumbly=3,falling_node=1,not_in_creative_inventory=1}, drop = '', on_rightclick = function(pos, node, clicker, itemstack) if clicker:get_hp() < 20 then diff --git a/mods/craftingpack/crafting/creative.lua b/mods/craftingpack/crafting/creative.lua index 42f663d06f..5fd6fd6f2e 100644 --- a/mods/craftingpack/crafting/creative.lua +++ b/mods/craftingpack/crafting/creative.lua @@ -62,7 +62,7 @@ function set_inv(filter, player) table.insert(creative_list, name) end elseif filter == "#food" then - if def.groups.food ~= nil then + if def.groups.food or def.groups.eatable then table.insert(creative_list, name) end elseif filter == "#tools" then @@ -70,7 +70,7 @@ function set_inv(filter, player) table.insert(creative_list, name) end elseif filter == "#combat" then - if def.tool_capabilities ~= nil and (string.find(string.lower(def.description), "sword") or string.find(string.lower(def.name), "armor") or string.find(string.lower(def.description), "bow") or string.find(string.lower(def.description), "arrow")) or string.find(string.lower(def.name), "armor") then + if (def.tool_capabilities ~= nil and def.tool_capabilities.damage_groups ~= nil) or def.groups.weapon or def.groups.weapon_ranged or def.groups.ammo or def.groups.armor_head or def.groups.armor_torso or def.groups.armor_legs or def.groups.armor_feet then table.insert(creative_list, name) end elseif filter == "#matr" then diff --git a/mods/default/craftitems.lua b/mods/default/craftitems.lua index 8038e360ad..10935a2bc9 100644 --- a/mods/default/craftitems.lua +++ b/mods/default/craftitems.lua @@ -166,6 +166,7 @@ minetest.register_craftitem("default:apple", { inventory_image = "default_apple.png", stack_max = 64, on_use = minetest.item_eat(4), + groups = { food = 2 }, }) minetest.register_craftitem("default:apple_gold", { @@ -174,6 +175,7 @@ minetest.register_craftitem("default:apple_gold", { inventory_image = "default_apple_gold.png", stack_max = 64, on_use = minetest.item_eat(8), + groups = { food = 2 }, }) minetest.register_alias("default:iron_ingot", "default:steel_ingot") diff --git a/mods/farming/carrots.lua b/mods/farming/carrots.lua index 6562b4d4f8..3a3326bd52 100644 --- a/mods/farming/carrots.lua +++ b/mods/farming/carrots.lua @@ -68,6 +68,7 @@ minetest.register_craftitem("farming:carrot_item", { description = "Carrot", inventory_image = "farming_carrot.png", on_use = minetest.item_eat(3), + groups = { food = 2, eatable = 3 }, on_place = function(itemstack, placer, pointed_thing) return farming:place_seed(itemstack, placer, pointed_thing, "farming:carrot_1") end @@ -77,6 +78,7 @@ minetest.register_craftitem("farming:carrot_item_gold", { description = "Golden Carrot", inventory_image = "farming_carrot_gold.png", on_use = minetest.item_eat(3), + groups = { food = 2, eatable = 3 }, }) minetest.register_craft({ diff --git a/mods/farming/melon.lua b/mods/farming/melon.lua index 5700efb4cb..c6e4a48daa 100644 --- a/mods/farming/melon.lua +++ b/mods/farming/melon.lua @@ -216,6 +216,7 @@ minetest.register_craftitem("farming:melon_item", { stack_max = 64, inventory_image = "farming_melon.png", on_use = minetest.item_eat(2), + groups = { food = 2, eatable = 2 }, }) minetest.register_craftitem("farming:speckled_melon", { diff --git a/mods/farming/mushrooms.lua b/mods/farming/mushrooms.lua index 56834e635b..4f7861ec70 100644 --- a/mods/farming/mushrooms.lua +++ b/mods/farming/mushrooms.lua @@ -37,6 +37,7 @@ minetest.register_craftitem("farming:mushroom_stew", { description = "Mushroom Stew", inventory_image = "farming_mushroom_stew.png", on_use = minetest.item_eat(6), + groups = { food = 2, eatable = 6 }, stack_max = 64, }) diff --git a/mods/farming/potatoes.lua b/mods/farming/potatoes.lua index 4a9950c903..e3689b77d2 100644 --- a/mods/farming/potatoes.lua +++ b/mods/farming/potatoes.lua @@ -51,6 +51,7 @@ minetest.register_craftitem("farming:potato_item", { description = "Potato", inventory_image = "farming_potato.png", on_use = minetest.item_eat(1), + groups = { food = 2, eatable = 1 }, stack_max = 64, on_place = function(itemstack, placer, pointed_thing) return farming:place_seed(itemstack, placer, pointed_thing, "farming:potato_1") @@ -62,6 +63,7 @@ minetest.register_craftitem("farming:potato_item_baked", { stack_max = 64, inventory_image = "farming_potato_baked.png", on_use = minetest.item_eat(6), + groups = { food = 2, eatable = 6 }, }) minetest.register_craftitem("farming:potato_item_poison", { @@ -69,6 +71,7 @@ minetest.register_craftitem("farming:potato_item_poison", { stack_max = 64, inventory_image = "farming_potato_poison.png", on_use = minetest.item_eat(2), + groups = { food = 2, eatable = 2 }, }) minetest.register_craft({ diff --git a/mods/farming/wheat.lua b/mods/farming/wheat.lua index 5cd874469a..89f2d6ae1a 100644 --- a/mods/farming/wheat.lua +++ b/mods/farming/wheat.lua @@ -146,7 +146,7 @@ minetest.register_craft({ minetest.register_craftitem("farming:cookie", { description = "Cookie", inventory_image = "farming_cookie.png", - groups = {food=2}, + groups = {food=2, eatable=2}, on_use = minetest.item_eat(2) }) @@ -154,7 +154,7 @@ minetest.register_craftitem("farming:cookie", { minetest.register_craftitem("farming:bread", { description = "Bread", inventory_image = "farming_bread.png", - groups = {food=2}, + groups = {food=2, eatable=5}, on_use = minetest.item_eat(5) }) diff --git a/mods/mobs/item.lua b/mods/mobs/item.lua index 8559860784..feacdb850f 100644 --- a/mods/mobs/item.lua +++ b/mods/mobs/item.lua @@ -86,12 +86,15 @@ minetest.register_craftitem("mobs:creeper", { -- Drop de monstre -- --------------------- +-- TODO: Add special status effects for raw flesh + minetest.register_craftitem("mobs:rotten_flesh", { description = "Rotten Flesh", inventory_image = "rotten_flesh.png", wield_image = "rotten_flesh.png", -- TODO: Raise to 4 on_use = minetest.item_eat(1), + groups = { food = 2, eatable = 1 }, stack_max = 64, }) @@ -100,6 +103,7 @@ minetest.register_craftitem("mobs:mutton", { inventory_image = "mutton_raw.png", wield_image = "mutton_raw.png", on_use = minetest.item_eat(2), + groups = { food = 2, eatable = 2 }, stack_max = 64, }) @@ -108,6 +112,7 @@ minetest.register_craftitem("mobs:cooked_mutton", { inventory_image = "mutton_cooked.png", wield_image = "mutton_cooked.png", on_use = minetest.item_eat(6), + groups = { food = 2, eatable = 6 }, stack_max = 64, }) @@ -116,6 +121,7 @@ minetest.register_craftitem("mobs:beef", { inventory_image = "mobs_beef_raw.png", wield_image = "mobs_beef_raw.png", on_use = minetest.item_eat(3), + groups = { food = 2, eatable = 3 }, stack_max = 64, }) @@ -124,6 +130,7 @@ minetest.register_craftitem("mobs:cooked_beef", { inventory_image = "mobs_beef_cooked.png", wield_image = "mobs_beef_cooked.png", on_use = minetest.item_eat(8), + groups = { food = 2, eatable = 8 }, stack_max = 64, }) @@ -132,6 +139,7 @@ minetest.register_craftitem("mobs:chicken", { inventory_image = "mobs_chicken_raw.png", wield_image = "mobs_chicken_raw.png", on_use = minetest.item_eat(2), + groups = { food = 2, eatable = 2 }, stack_max = 64, }) @@ -140,6 +148,7 @@ minetest.register_craftitem("mobs:cooked_chicken", { inventory_image = "mobs_chicken_cooked.png", wield_image = "mobs_chicken_cooked.png", on_use = minetest.item_eat(6), + groups = { food = 2, eatable = 6 }, stack_max = 64, }) @@ -148,6 +157,7 @@ minetest.register_craftitem("mobs:porkchop", { inventory_image = "mobs_porkchop_raw.png", wield_image = "mobs_porkchop.png", on_use = minetest.item_eat(3), + groups = { food = 2, eatable = 3 }, stack_max = 64, }) @@ -156,6 +166,7 @@ minetest.register_craftitem("mobs:cooked_porkchop", { inventory_image = "mobs_porkchop_cooked.png", wield_image = "mobs_porkchop_cooked.png", on_use = minetest.item_eat(8), + groups = { food = 2, eatable = 8 }, stack_max = 64, }) @@ -164,6 +175,7 @@ minetest.register_craftitem("mobs:rabbit", { inventory_image = "mobs_rabbit_raw.png", wield_image = "mobs_rabbit_raw.png", on_use = minetest.item_eat(3), + groups = { food = 2, eatable = 3 }, stack_max = 64, }) @@ -172,6 +184,7 @@ minetest.register_craftitem("mobs:cooked_rabbit", { inventory_image = "mobs_rabbit_cooked.png", wield_image = "mobs_rabbit_cooked.png", on_use = minetest.item_eat(5), + groups = { food = 2, eatable = 5 }, stack_max = 64, }) @@ -180,6 +193,7 @@ minetest.register_craftitem("mobs:spider_eye", { inventory_image = "spider_eye.png", wield_image = "spider_eye.png", on_use = minetest.item_eat(2), + groups = { food = 2, eatable = 2 }, stack_max = 64, }) diff --git a/mods/throwing/arrow.lua b/mods/throwing/arrow.lua index 523567659a..6acaf0c2a8 100644 --- a/mods/throwing/arrow.lua +++ b/mods/throwing/arrow.lua @@ -1,6 +1,7 @@ minetest.register_craftitem("throwing:arrow", { description = "Arrow", inventory_image = "throwing_arrow_inv.png", + groups = { ammo=1, ammo_bow=1 }, }) minetest.register_node("throwing:arrow_box", { diff --git a/mods/throwing/init.lua b/mods/throwing/init.lua index a92d53e7bf..a1eb384b83 100644 --- a/mods/throwing/init.lua +++ b/mods/throwing/init.lua @@ -36,6 +36,7 @@ minetest.register_tool("throwing:bow", { itemstack:add_wear(wear) return itemstack end, + groups = {weapon_ranged=1,}, on_use = function(itemstack, user, pointed_thing) local wear = itemstack:get_wear() itemstack:add_wear(wear)