Eat on rightclick

This commit is contained in:
Wuzzy 2017-02-16 17:45:33 +01:00
parent bbf7efc338
commit 96521433f5
11 changed files with 81 additions and 39 deletions

View file

@ -138,7 +138,8 @@ minetest.register_craftitem("mcl_core:apple", {
wield_image = "default_apple.png", wield_image = "default_apple.png",
inventory_image = "default_apple.png", inventory_image = "default_apple.png",
stack_max = 64, stack_max = 64,
on_use = minetest.item_eat(4), on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2 }, groups = { food = 2 },
}) })
@ -147,6 +148,7 @@ minetest.register_craftitem("mcl_core:apple_gold", {
wield_image = "default_apple_gold.png", wield_image = "default_apple_gold.png",
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_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2 }, groups = { food = 2 },
}) })

View file

@ -193,7 +193,8 @@ minetest.register_craftitem("mcl_end:chorus_fruit", {
wield_image = "mcl_end_chorus_fruit.png", wield_image = "mcl_end_chorus_fruit.png",
inventory_image = "mcl_end_chorus_fruit.png", inventory_image = "mcl_end_chorus_fruit.png",
-- TODO: Teleport player -- TODO: Teleport player
on_use = minetest.item_eat(4), on_place = minetest.item_eat(4),
on_secondary_use = minetest.item_eat(4),
groups = { food = 2, eatable = 4 }, groups = { food = 2, eatable = 4 },
stack_max = 64, stack_max = 64,
}) })

View file

@ -92,7 +92,8 @@ minetest.register_craftitem("mcl_farming:beetroot_item", {
description = "Beetroot", description = "Beetroot",
inventory_image = "mcl_farming_beetroot.png", inventory_image = "mcl_farming_beetroot.png",
wield_image = "mcl_farming_beetroot.png", wield_image = "mcl_farming_beetroot.png",
on_use = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1 },
}) })
@ -101,7 +102,8 @@ minetest.register_craftitem("mcl_farming:beetroot_soup", {
stack_max = 1, stack_max = 1,
inventory_image = "mcl_farming_beetroot_soup.png", inventory_image = "mcl_farming_beetroot_soup.png",
wield_image = "mcl_farming_beetroot_soup.png", wield_image = "mcl_farming_beetroot_soup.png",
on_use = minetest.item_eat(6, "mcl_core:bowl"), on_place = minetest.item_eat(6, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(6, "mcl_core:bowl"),
groups = { food = 3, eatable = 6 }, groups = { food = 3, eatable = 6 },
}) })

View file

@ -67,17 +67,23 @@ minetest.register_node("mcl_farming:carrot", {
minetest.register_craftitem("mcl_farming:carrot_item", { minetest.register_craftitem("mcl_farming:carrot_item", {
description = "Carrot", description = "Carrot",
inventory_image = "farming_carrot.png", inventory_image = "farming_carrot.png",
on_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 }, groups = { food = 2, eatable = 3 },
on_secondary_use = minetest.item_eat(3),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1") local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1")
if new ~= nil then
return new
else
return minetest.do_item_eat(3, nil, itemstack, placer, pointed_thing)
end end
end,
}) })
minetest.register_craftitem("mcl_farming:carrot_item_gold", { minetest.register_craftitem("mcl_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_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { brewitem = 1, food = 2, eatable = 3 }, groups = { brewitem = 1, food = 2, eatable = 3 },
}) })

View file

@ -216,7 +216,8 @@ minetest.register_craftitem("mcl_farming:melon_item", {
description = "Melon", description = "Melon",
stack_max = 64, stack_max = 64,
inventory_image = "farming_melon.png", inventory_image = "farming_melon.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2 },
}) })

View file

@ -36,7 +36,8 @@ minetest.register_node("mcl_farming:mushroom_red", {
minetest.register_craftitem("mcl_farming:mushroom_stew", { minetest.register_craftitem("mcl_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, "mcl_core:bowl"), on_place = minetest.item_eat(6, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(6, "mcl_core:bowl"),
groups = { food = 3, eatable = 6 }, groups = { food = 3, eatable = 6 },
stack_max = 1, stack_max = 1,
}) })

View file

@ -50,11 +50,16 @@ minetest.register_node("mcl_farming:potato", {
minetest.register_craftitem("mcl_farming:potato_item", { minetest.register_craftitem("mcl_farming:potato_item", {
description = "Potato", description = "Potato",
inventory_image = "farming_potato.png", inventory_image = "farming_potato.png",
on_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1 },
stack_max = 64, stack_max = 64,
on_secondary_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:potato_1") local new = mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:potato_1")
if new ~= nil then
return new
else
return minetest.do_item_eat(1, nil, itemstack, placer, pointed_thing)
end
end, end,
}) })
@ -62,7 +67,8 @@ minetest.register_craftitem("mcl_farming:potato_item_baked", {
description = "Baked Potato", description = "Baked Potato",
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_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 }, groups = { food = 2, eatable = 6 },
}) })
@ -70,7 +76,8 @@ minetest.register_craftitem("mcl_farming:potato_item_poison", {
description = "Poisonous Potato", description = "Poisonous Potato",
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_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2 },
}) })

View file

@ -287,7 +287,8 @@ minetest.register_craftitem("mcl_farming:pumpkin_pie", {
stack_max = 64, stack_max = 64,
inventory_image = "mcl_farming_pumpkin_pie.png", inventory_image = "mcl_farming_pumpkin_pie.png",
wield_image = "mcl_farming_pumpkin_pie.png", wield_image = "mcl_farming_pumpkin_pie.png",
on_use = minetest.item_eat(8), on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 }, groups = { food = 2, eatable = 8 },
}) })

View file

@ -149,7 +149,8 @@ minetest.register_craftitem("mcl_farming:cookie", {
description = "Cookie", description = "Cookie",
inventory_image = "farming_cookie.png", inventory_image = "farming_cookie.png",
groups = {food=2, eatable=2}, groups = {food=2, eatable=2},
on_use = minetest.item_eat(2) on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
}) })
@ -157,6 +158,7 @@ minetest.register_craftitem("mcl_farming:bread", {
description = "Bread", description = "Bread",
inventory_image = "farming_bread.png", inventory_image = "farming_bread.png",
groups = {food=2, eatable=5}, groups = {food=2, eatable=5},
on_use = minetest.item_eat(5) on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5),
}) })

View file

@ -121,7 +121,8 @@ minetest.register_craft({
minetest.register_craftitem("mcl_fishing:fish_raw", { minetest.register_craftitem("mcl_fishing:fish_raw", {
description = "Raw Fish", description = "Raw Fish",
inventory_image = "mcl_fishing_fish_raw.png", inventory_image = "mcl_fishing_fish_raw.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable = 2 }, groups = { food=2, eatable = 2 },
}) })
@ -129,7 +130,8 @@ minetest.register_craftitem("mcl_fishing:fish_raw", {
minetest.register_craftitem("mcl_fishing:fish_cooked", { minetest.register_craftitem("mcl_fishing:fish_cooked", {
description = "Cooked Fish", description = "Cooked Fish",
inventory_image = "mcl_fishing_fish_cooked.png", inventory_image = "mcl_fishing_fish_cooked.png",
on_use = minetest.item_eat(5), on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable=5 }, groups = { food=2, eatable=5 },
}) })
@ -145,7 +147,8 @@ minetest.register_craft({
minetest.register_craftitem("mcl_fishing:salmon_raw", { minetest.register_craftitem("mcl_fishing:salmon_raw", {
description = "Raw Salmon", description = "Raw Salmon",
inventory_image = "mcl_fishing_salmon_raw.png", inventory_image = "mcl_fishing_salmon_raw.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable = 2 }, groups = { food=2, eatable = 2 },
}) })
@ -153,7 +156,8 @@ minetest.register_craftitem("mcl_fishing:salmon_raw", {
minetest.register_craftitem("mcl_fishing:salmon_cooked", { minetest.register_craftitem("mcl_fishing:salmon_cooked", {
description = "Cooked Salmon", description = "Cooked Salmon",
inventory_image = "mcl_fishing_salmon_cooked.png", inventory_image = "mcl_fishing_salmon_cooked.png",
on_use = minetest.item_eat(6), on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable=6 }, groups = { food=2, eatable=6 },
}) })
@ -169,7 +173,8 @@ minetest.register_craft({
minetest.register_craftitem("mcl_fishing:clownfish_raw", { minetest.register_craftitem("mcl_fishing:clownfish_raw", {
description = "Clownfish", description = "Clownfish",
inventory_image = "mcl_fishing_clownfish_raw.png", inventory_image = "mcl_fishing_clownfish_raw.png",
on_use = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable = 1 }, groups = { food=2, eatable = 1 },
}) })
@ -178,7 +183,8 @@ minetest.register_craftitem("mcl_fishing:clownfish_raw", {
minetest.register_craftitem("mcl_fishing:pufferfish_raw", { minetest.register_craftitem("mcl_fishing:pufferfish_raw", {
description = "Pufferfish", description = "Pufferfish",
inventory_image = "mcl_fishing_pufferfish_raw.png", inventory_image = "mcl_fishing_pufferfish_raw.png",
on_use = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1),
stack_max = 64, stack_max = 64,
groups = { food=2, eatable=1 }, groups = { food=2, eatable=1 },
}) })

View file

@ -5,7 +5,8 @@ minetest.register_craftitem("mcl_mobitems:rotten_flesh", {
inventory_image = "mcl_mobitems_rotten_flesh.png", inventory_image = "mcl_mobitems_rotten_flesh.png",
wield_image = "mcl_mobitems_rotten_flesh.png", wield_image = "mcl_mobitems_rotten_flesh.png",
-- TODO: Raise to 4 -- TODO: Raise to 4
on_use = minetest.item_eat(1), on_place = minetest.item_eat(1),
on_secondary_use = minetest.item_eat(1),
groups = { food = 2, eatable = 1 }, groups = { food = 2, eatable = 1 },
stack_max = 64, stack_max = 64,
}) })
@ -14,7 +15,8 @@ minetest.register_craftitem("mcl_mobitems:mutton", {
description = "Raw Mutton", description = "Raw Mutton",
inventory_image = "mcl_mobitems_mutton_raw.png", inventory_image = "mcl_mobitems_mutton_raw.png",
wield_image = "mcl_mobitems_mutton_raw.png", wield_image = "mcl_mobitems_mutton_raw.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })
@ -23,7 +25,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_mutton", {
description = "Cooked Mutton", description = "Cooked Mutton",
inventory_image = "mcl_mobitems_mutton_cooked.png", inventory_image = "mcl_mobitems_mutton_cooked.png",
wield_image = "mcl_mobitems_mutton_cooked.png", wield_image = "mcl_mobitems_mutton_cooked.png",
on_use = minetest.item_eat(6), on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 }, groups = { food = 2, eatable = 6 },
stack_max = 64, stack_max = 64,
}) })
@ -32,7 +35,8 @@ minetest.register_craftitem("mcl_mobitems:beef", {
description = "Raw Beef", description = "Raw Beef",
inventory_image = "mcl_mobitems_beef_raw.png", inventory_image = "mcl_mobitems_beef_raw.png",
wield_image = "mcl_mobitems_beef_raw.png", wield_image = "mcl_mobitems_beef_raw.png",
on_use = minetest.item_eat(3), on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 }, groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -41,7 +45,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_beef", {
description = "Steak", description = "Steak",
inventory_image = "mcl_mobitems_beef_cooked.png", inventory_image = "mcl_mobitems_beef_cooked.png",
wield_image = "mcl_mobitems_beef_cooked.png", wield_image = "mcl_mobitems_beef_cooked.png",
on_use = minetest.item_eat(8), on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 }, groups = { food = 2, eatable = 8 },
stack_max = 64, stack_max = 64,
}) })
@ -50,7 +55,8 @@ minetest.register_craftitem("mcl_mobitems:chicken", {
description = "Raw Chicken", description = "Raw Chicken",
inventory_image = "mcl_mobitems_chicken_raw.png", inventory_image = "mcl_mobitems_chicken_raw.png",
wield_image = "mcl_mobitems_chicken_raw.png", wield_image = "mcl_mobitems_chicken_raw.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })
@ -59,7 +65,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_chicken", {
description = "Cooked Chicken", description = "Cooked Chicken",
inventory_image = "mcl_mobitems_chicken_cooked.png", inventory_image = "mcl_mobitems_chicken_cooked.png",
wield_image = "mcl_mobitems_chicken_cooked.png", wield_image = "mcl_mobitems_chicken_cooked.png",
on_use = minetest.item_eat(6), on_place = minetest.item_eat(6),
on_secondary_use = minetest.item_eat(6),
groups = { food = 2, eatable = 6 }, groups = { food = 2, eatable = 6 },
stack_max = 64, stack_max = 64,
}) })
@ -68,7 +75,8 @@ minetest.register_craftitem("mcl_mobitems:porkchop", {
description = "Raw Porkchop", description = "Raw Porkchop",
inventory_image = "mcl_mobitems_porkchop_raw.png", inventory_image = "mcl_mobitems_porkchop_raw.png",
wield_image = "mcl_mobitems_porkchop_raw.png", wield_image = "mcl_mobitems_porkchop_raw.png",
on_use = minetest.item_eat(3), on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 }, groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -77,7 +85,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_porkchop", {
description = "Cooked Porkchop", description = "Cooked Porkchop",
inventory_image = "mcl_mobitems_porkchop_cooked.png", inventory_image = "mcl_mobitems_porkchop_cooked.png",
wield_image = "mcl_mobitems_porkchop_cooked.png", wield_image = "mcl_mobitems_porkchop_cooked.png",
on_use = minetest.item_eat(8), on_place = minetest.item_eat(8),
on_secondary_use = minetest.item_eat(8),
groups = { food = 2, eatable = 8 }, groups = { food = 2, eatable = 8 },
stack_max = 64, stack_max = 64,
}) })
@ -86,7 +95,8 @@ minetest.register_craftitem("mcl_mobitems:rabbit", {
description = "Raw Rabbit", description = "Raw Rabbit",
inventory_image = "mcl_mobitems_rabbit_raw.png", inventory_image = "mcl_mobitems_rabbit_raw.png",
wield_image = "mcl_mobitems_rabbit_raw.png", wield_image = "mcl_mobitems_rabbit_raw.png",
on_use = minetest.item_eat(3), on_place = minetest.item_eat(3),
on_secondary_use = minetest.item_eat(3),
groups = { food = 2, eatable = 3 }, groups = { food = 2, eatable = 3 },
stack_max = 64, stack_max = 64,
}) })
@ -95,18 +105,19 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", {
description = "Cooked Rabbit", description = "Cooked Rabbit",
inventory_image = "mcl_mobitems_rabbit_cooked.png", inventory_image = "mcl_mobitems_rabbit_cooked.png",
wield_image = "mcl_mobitems_rabbit_cooked.png", wield_image = "mcl_mobitems_rabbit_cooked.png",
on_use = minetest.item_eat(5), on_place = minetest.item_eat(5),
on_secondary_use = minetest.item_eat(5),
groups = { food = 2, eatable = 5 }, groups = { food = 2, eatable = 5 },
stack_max = 64, stack_max = 64,
}) })
-- TODO: Fix drinking sound
-- TODO: Clear status effects -- TODO: Clear status effects
minetest.register_craftitem("mcl_mobitems:milk_bucket", { minetest.register_craftitem("mcl_mobitems:milk_bucket", {
description = "Milk", description = "Milk",
inventory_image = "mcl_mobitems_bucket_milk.png", inventory_image = "mcl_mobitems_bucket_milk.png",
wield_image = "mcl_mobitems_bucket_milk.png", wield_image = "mcl_mobitems_bucket_milk.png",
on_use = minetest.item_eat(0, "bucket:bucket_empty"), on_place = minetest.item_eat(0, "bucket:bucket_empty"),
on_secondary_use = minetest.item_eat(0, "bucket:bucket_empty"),
stack_max = 1, stack_max = 1,
groups = { food = 3 }, groups = { food = 3 },
}) })
@ -115,7 +126,8 @@ minetest.register_craftitem("mcl_mobitems:spider_eye", {
description = "Spider Eye", description = "Spider Eye",
inventory_image = "mcl_mobitems_spider_eye.png", inventory_image = "mcl_mobitems_spider_eye.png",
wield_image = "mcl_mobitems_spider_eye.png", wield_image = "mcl_mobitems_spider_eye.png",
on_use = minetest.item_eat(2), on_place = minetest.item_eat(2),
on_secondary_use = minetest.item_eat(2),
groups = { food = 2, eatable = 2 }, groups = { food = 2, eatable = 2 },
stack_max = 64, stack_max = 64,
}) })
@ -218,7 +230,8 @@ minetest.register_craftitem("mcl_mobitems:rabbit_stew", {
wield_image = "mcl_mobitems_rabbit_stew.png", wield_image = "mcl_mobitems_rabbit_stew.png",
inventory_image = "mcl_mobitems_rabbit_stew.png", inventory_image = "mcl_mobitems_rabbit_stew.png",
stack_max = 1, stack_max = 1,
on_use = minetest.item_eat(10, "mcl_core:bowl"), on_place = minetest.item_eat(10, "mcl_core:bowl"),
on_secondary_use = minetest.item_eat(10, "mcl_core:bowl"),
groups = { food = 3, eatable = 10 }, groups = { food = 3, eatable = 10 },
}) })