1
0
Fork 0

Clean up creative inventory tabs a little

This commit is contained in:
Wuzzy 2017-01-16 14:29:41 +01:00
parent d7cb7cb5a8
commit b150d227e1
12 changed files with 43 additions and 10 deletions

8
API.md
View File

@ -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_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 * `soil_sugarcane=1`: Sugar canes will grow on this near water
* `disable_suffocation=1`: Disables suffocation for full solid cubes (1) * `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 ### Footnotes

View File

@ -37,7 +37,7 @@ minetest.register_node("cake:cake", {
fixed = slice_6 fixed = slice_6
}, },
stack_max = 1, stack_max = 1,
groups = {crumbly=3,falling_node=1}, groups = {food=2,crumbly=3,falling_node=1},
drop = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
@ -60,7 +60,7 @@ minetest.register_node("cake:cake_5", {
type = "fixed", type = "fixed",
fixed = slice_5 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 = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
@ -83,7 +83,7 @@ minetest.register_node("cake:cake_4", {
type = "fixed", type = "fixed",
fixed = slice_4 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 = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
@ -106,7 +106,7 @@ minetest.register_node("cake:cake_3", {
type = "fixed", type = "fixed",
fixed = slice_3 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 = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
@ -129,7 +129,7 @@ minetest.register_node("cake:cake_2", {
type = "fixed", type = "fixed",
fixed = slice_2 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 = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then
@ -152,7 +152,7 @@ minetest.register_node("cake:cake_1", {
type = "fixed", type = "fixed",
fixed = slice_1 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 = '', drop = '',
on_rightclick = function(pos, node, clicker, itemstack) on_rightclick = function(pos, node, clicker, itemstack)
if clicker:get_hp() < 20 then if clicker:get_hp() < 20 then

View File

@ -62,7 +62,7 @@ function set_inv(filter, player)
table.insert(creative_list, name) table.insert(creative_list, name)
end end
elseif filter == "#food" then elseif filter == "#food" then
if def.groups.food ~= nil then if def.groups.food or def.groups.eatable then
table.insert(creative_list, name) table.insert(creative_list, name)
end end
elseif filter == "#tools" then elseif filter == "#tools" then
@ -70,7 +70,7 @@ function set_inv(filter, player)
table.insert(creative_list, name) table.insert(creative_list, name)
end end
elseif filter == "#combat" then 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) table.insert(creative_list, name)
end end
elseif filter == "#matr" then elseif filter == "#matr" then

View File

@ -166,6 +166,7 @@ minetest.register_craftitem("default:apple", {
inventory_image = "default_apple.png", inventory_image = "default_apple.png",
stack_max = 64, stack_max = 64,
on_use = minetest.item_eat(4), on_use = minetest.item_eat(4),
groups = { food = 2 },
}) })
minetest.register_craftitem("default:apple_gold", { minetest.register_craftitem("default:apple_gold", {
@ -174,6 +175,7 @@ minetest.register_craftitem("default:apple_gold", {
inventory_image = "default_apple_gold.png", inventory_image = "default_apple_gold.png",
stack_max = 64, stack_max = 64,
on_use = minetest.item_eat(8), on_use = minetest.item_eat(8),
groups = { food = 2 },
}) })
minetest.register_alias("default:iron_ingot", "default:steel_ingot") minetest.register_alias("default:iron_ingot", "default:steel_ingot")

View File

@ -68,6 +68,7 @@ minetest.register_craftitem("farming:carrot_item", {
description = "Carrot", description = "Carrot",
inventory_image = "farming_carrot.png", inventory_image = "farming_carrot.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming:carrot_1") return farming:place_seed(itemstack, placer, pointed_thing, "farming:carrot_1")
end end
@ -77,6 +78,7 @@ minetest.register_craftitem("farming:carrot_item_gold", {
description = "Golden Carrot", description = "Golden Carrot",
inventory_image = "farming_carrot_gold.png", inventory_image = "farming_carrot_gold.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -216,6 +216,7 @@ minetest.register_craftitem("farming:melon_item", {
stack_max = 64, stack_max = 64,
inventory_image = "farming_melon.png", inventory_image = "farming_melon.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
}) })
minetest.register_craftitem("farming:speckled_melon", { minetest.register_craftitem("farming:speckled_melon", {

View File

@ -37,6 +37,7 @@ minetest.register_craftitem("farming:mushroom_stew", {
description = "Mushroom Stew", description = "Mushroom Stew",
inventory_image = "farming_mushroom_stew.png", inventory_image = "farming_mushroom_stew.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
stack_max = 64, stack_max = 64,
}) })

View File

@ -51,6 +51,7 @@ minetest.register_craftitem("farming:potato_item", {
description = "Potato", description = "Potato",
inventory_image = "farming_potato.png", inventory_image = "farming_potato.png",
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 },
stack_max = 64, stack_max = 64,
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return farming:place_seed(itemstack, placer, pointed_thing, "farming:potato_1") 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, stack_max = 64,
inventory_image = "farming_potato_baked.png", inventory_image = "farming_potato_baked.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
}) })
minetest.register_craftitem("farming:potato_item_poison", { minetest.register_craftitem("farming:potato_item_poison", {
@ -69,6 +71,7 @@ minetest.register_craftitem("farming:potato_item_poison", {
stack_max = 64, stack_max = 64,
inventory_image = "farming_potato_poison.png", inventory_image = "farming_potato_poison.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
}) })
minetest.register_craft({ minetest.register_craft({

View File

@ -146,7 +146,7 @@ minetest.register_craft({
minetest.register_craftitem("farming:cookie", { minetest.register_craftitem("farming:cookie", {
description = "Cookie", description = "Cookie",
inventory_image = "farming_cookie.png", inventory_image = "farming_cookie.png",
groups = {food=2}, groups = {food=2, eatable=2},
on_use = minetest.item_eat(2) on_use = minetest.item_eat(2)
}) })
@ -154,7 +154,7 @@ minetest.register_craftitem("farming:cookie", {
minetest.register_craftitem("farming:bread", { minetest.register_craftitem("farming:bread", {
description = "Bread", description = "Bread",
inventory_image = "farming_bread.png", inventory_image = "farming_bread.png",
groups = {food=2}, groups = {food=2, eatable=5},
on_use = minetest.item_eat(5) on_use = minetest.item_eat(5)
}) })

View File

@ -86,12 +86,15 @@ minetest.register_craftitem("mobs:creeper", {
-- Drop de monstre -- -- Drop de monstre --
--------------------- ---------------------
-- TODO: Add special status effects for raw flesh
minetest.register_craftitem("mobs:rotten_flesh", { minetest.register_craftitem("mobs:rotten_flesh", {
description = "Rotten Flesh", description = "Rotten Flesh",
inventory_image = "rotten_flesh.png", inventory_image = "rotten_flesh.png",
wield_image = "rotten_flesh.png", wield_image = "rotten_flesh.png",
-- TODO: Raise to 4 -- TODO: Raise to 4
on_use = minetest.item_eat(1), on_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 },
stack_max = 64, stack_max = 64,
}) })
@ -100,6 +103,7 @@ minetest.register_craftitem("mobs:mutton", {
inventory_image = "mutton_raw.png", inventory_image = "mutton_raw.png",
wield_image = "mutton_raw.png", wield_image = "mutton_raw.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })
@ -108,6 +112,7 @@ minetest.register_craftitem("mobs:cooked_mutton", {
inventory_image = "mutton_cooked.png", inventory_image = "mutton_cooked.png",
wield_image = "mutton_cooked.png", wield_image = "mutton_cooked.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
stack_max = 64, stack_max = 64,
}) })
@ -116,6 +121,7 @@ minetest.register_craftitem("mobs:beef", {
inventory_image = "mobs_beef_raw.png", inventory_image = "mobs_beef_raw.png",
wield_image = "mobs_beef_raw.png", wield_image = "mobs_beef_raw.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -124,6 +130,7 @@ minetest.register_craftitem("mobs:cooked_beef", {
inventory_image = "mobs_beef_cooked.png", inventory_image = "mobs_beef_cooked.png",
wield_image = "mobs_beef_cooked.png", wield_image = "mobs_beef_cooked.png",
on_use = minetest.item_eat(8), on_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
stack_max = 64, stack_max = 64,
}) })
@ -132,6 +139,7 @@ minetest.register_craftitem("mobs:chicken", {
inventory_image = "mobs_chicken_raw.png", inventory_image = "mobs_chicken_raw.png",
wield_image = "mobs_chicken_raw.png", wield_image = "mobs_chicken_raw.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })
@ -140,6 +148,7 @@ minetest.register_craftitem("mobs:cooked_chicken", {
inventory_image = "mobs_chicken_cooked.png", inventory_image = "mobs_chicken_cooked.png",
wield_image = "mobs_chicken_cooked.png", wield_image = "mobs_chicken_cooked.png",
on_use = minetest.item_eat(6), on_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 },
stack_max = 64, stack_max = 64,
}) })
@ -148,6 +157,7 @@ minetest.register_craftitem("mobs:porkchop", {
inventory_image = "mobs_porkchop_raw.png", inventory_image = "mobs_porkchop_raw.png",
wield_image = "mobs_porkchop.png", wield_image = "mobs_porkchop.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -156,6 +166,7 @@ minetest.register_craftitem("mobs:cooked_porkchop", {
inventory_image = "mobs_porkchop_cooked.png", inventory_image = "mobs_porkchop_cooked.png",
wield_image = "mobs_porkchop_cooked.png", wield_image = "mobs_porkchop_cooked.png",
on_use = minetest.item_eat(8), on_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 },
stack_max = 64, stack_max = 64,
}) })
@ -164,6 +175,7 @@ minetest.register_craftitem("mobs:rabbit", {
inventory_image = "mobs_rabbit_raw.png", inventory_image = "mobs_rabbit_raw.png",
wield_image = "mobs_rabbit_raw.png", wield_image = "mobs_rabbit_raw.png",
on_use = minetest.item_eat(3), on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -172,6 +184,7 @@ minetest.register_craftitem("mobs:cooked_rabbit", {
inventory_image = "mobs_rabbit_cooked.png", inventory_image = "mobs_rabbit_cooked.png",
wield_image = "mobs_rabbit_cooked.png", wield_image = "mobs_rabbit_cooked.png",
on_use = minetest.item_eat(5), on_use = minetest.item_eat(5),
groups = { food = 2, eatable = 5 },
stack_max = 64, stack_max = 64,
}) })
@ -180,6 +193,7 @@ minetest.register_craftitem("mobs:spider_eye", {
inventory_image = "spider_eye.png", inventory_image = "spider_eye.png",
wield_image = "spider_eye.png", wield_image = "spider_eye.png",
on_use = minetest.item_eat(2), on_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })

View File

@ -1,6 +1,7 @@
minetest.register_craftitem("throwing:arrow", { minetest.register_craftitem("throwing:arrow", {
description = "Arrow", description = "Arrow",
inventory_image = "throwing_arrow_inv.png", inventory_image = "throwing_arrow_inv.png",
groups = { ammo=1, ammo_bow=1 },
}) })
minetest.register_node("throwing:arrow_box", { minetest.register_node("throwing:arrow_box", {

View File

@ -36,6 +36,7 @@ minetest.register_tool("throwing:bow", {
itemstack:add_wear(wear) itemstack:add_wear(wear)
return itemstack return itemstack
end, end,
groups = {weapon_ranged=1,},
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear() local wear = itemstack:get_wear()
itemstack:add_wear(wear) itemstack:add_wear(wear)