From 96521433f5042a34fcb12ea9aa3b9451308112c6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 16 Feb 2017 17:45:33 +0100 Subject: [PATCH] Eat on rightclick --- mods/CORE/mcl_core/craftitems.lua | 6 ++-- mods/ITEMS/mcl_end/init.lua | 3 +- mods/ITEMS/mcl_farming/beetroot.lua | 6 ++-- mods/ITEMS/mcl_farming/carrots.lua | 14 ++++++--- mods/ITEMS/mcl_farming/melon.lua | 3 +- mods/ITEMS/mcl_farming/mushrooms.lua | 3 +- mods/ITEMS/mcl_farming/potatoes.lua | 15 +++++++--- mods/ITEMS/mcl_farming/pumpkin.lua | 3 +- mods/ITEMS/mcl_farming/wheat.lua | 6 ++-- mods/ITEMS/mcl_fishing/init.lua | 18 ++++++++---- mods/ITEMS/mcl_mobitems/init.lua | 43 ++++++++++++++++++---------- 11 files changed, 81 insertions(+), 39 deletions(-) diff --git a/mods/CORE/mcl_core/craftitems.lua b/mods/CORE/mcl_core/craftitems.lua index ba7a6308a2..4392859cfd 100644 --- a/mods/CORE/mcl_core/craftitems.lua +++ b/mods/CORE/mcl_core/craftitems.lua @@ -138,7 +138,8 @@ minetest.register_craftitem("mcl_core:apple", { wield_image = "default_apple.png", inventory_image = "default_apple.png", 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 }, }) @@ -147,6 +148,7 @@ minetest.register_craftitem("mcl_core:apple_gold", { wield_image = "default_apple_gold.png", inventory_image = "default_apple_gold.png", 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 }, }) diff --git a/mods/ITEMS/mcl_end/init.lua b/mods/ITEMS/mcl_end/init.lua index cdf95aaeb8..ae3f3d4fa4 100644 --- a/mods/ITEMS/mcl_end/init.lua +++ b/mods/ITEMS/mcl_end/init.lua @@ -193,7 +193,8 @@ minetest.register_craftitem("mcl_end:chorus_fruit", { wield_image = "mcl_end_chorus_fruit.png", inventory_image = "mcl_end_chorus_fruit.png", -- 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 }, stack_max = 64, }) diff --git a/mods/ITEMS/mcl_farming/beetroot.lua b/mods/ITEMS/mcl_farming/beetroot.lua index f1a2003714..96fb448e48 100644 --- a/mods/ITEMS/mcl_farming/beetroot.lua +++ b/mods/ITEMS/mcl_farming/beetroot.lua @@ -92,7 +92,8 @@ minetest.register_craftitem("mcl_farming:beetroot_item", { description = "Beetroot", inventory_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 }, }) @@ -101,7 +102,8 @@ minetest.register_craftitem("mcl_farming:beetroot_soup", { stack_max = 1, inventory_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 }, }) diff --git a/mods/ITEMS/mcl_farming/carrots.lua b/mods/ITEMS/mcl_farming/carrots.lua index 91dd902043..26e389840f 100644 --- a/mods/ITEMS/mcl_farming/carrots.lua +++ b/mods/ITEMS/mcl_farming/carrots.lua @@ -67,17 +67,23 @@ minetest.register_node("mcl_farming:carrot", { minetest.register_craftitem("mcl_farming:carrot_item", { description = "Carrot", inventory_image = "farming_carrot.png", - on_use = minetest.item_eat(3), groups = { food = 2, eatable = 3 }, + on_secondary_use = minetest.item_eat(3), on_place = function(itemstack, placer, pointed_thing) - return mcl_farming:place_seed(itemstack, placer, pointed_thing, "mcl_farming:carrot_1") - end + 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, }) minetest.register_craftitem("mcl_farming:carrot_item_gold", { description = "Golden Carrot", 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 }, }) diff --git a/mods/ITEMS/mcl_farming/melon.lua b/mods/ITEMS/mcl_farming/melon.lua index 265bb18afa..563b912d54 100644 --- a/mods/ITEMS/mcl_farming/melon.lua +++ b/mods/ITEMS/mcl_farming/melon.lua @@ -216,7 +216,8 @@ minetest.register_craftitem("mcl_farming:melon_item", { description = "Melon", stack_max = 64, 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 }, }) diff --git a/mods/ITEMS/mcl_farming/mushrooms.lua b/mods/ITEMS/mcl_farming/mushrooms.lua index 0dc4f52505..d7a3f5f468 100644 --- a/mods/ITEMS/mcl_farming/mushrooms.lua +++ b/mods/ITEMS/mcl_farming/mushrooms.lua @@ -36,7 +36,8 @@ minetest.register_node("mcl_farming:mushroom_red", { minetest.register_craftitem("mcl_farming:mushroom_stew", { description = "Mushroom Stew", 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 }, stack_max = 1, }) diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index af9c979bc4..64112d924a 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -50,11 +50,16 @@ minetest.register_node("mcl_farming:potato", { minetest.register_craftitem("mcl_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_secondary_use = minetest.item_eat(1), 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, }) @@ -62,7 +67,8 @@ minetest.register_craftitem("mcl_farming:potato_item_baked", { description = "Baked Potato", stack_max = 64, 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 }, }) @@ -70,7 +76,8 @@ minetest.register_craftitem("mcl_farming:potato_item_poison", { description = "Poisonous Potato", stack_max = 64, 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 }, }) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index acd6a4940f..e2fdc6a8b6 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -287,7 +287,8 @@ minetest.register_craftitem("mcl_farming:pumpkin_pie", { stack_max = 64, inventory_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 }, }) diff --git a/mods/ITEMS/mcl_farming/wheat.lua b/mods/ITEMS/mcl_farming/wheat.lua index a68c6b0bef..b2f1187297 100644 --- a/mods/ITEMS/mcl_farming/wheat.lua +++ b/mods/ITEMS/mcl_farming/wheat.lua @@ -149,7 +149,8 @@ minetest.register_craftitem("mcl_farming:cookie", { description = "Cookie", inventory_image = "farming_cookie.png", 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", inventory_image = "farming_bread.png", groups = {food=2, eatable=5}, - on_use = minetest.item_eat(5) + on_place = minetest.item_eat(5), + on_secondary_use = minetest.item_eat(5), }) diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index f356cc6a20..efd8c01b67 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -121,7 +121,8 @@ minetest.register_craft({ minetest.register_craftitem("mcl_fishing:fish_raw", { description = "Raw Fish", 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, groups = { food=2, eatable = 2 }, }) @@ -129,7 +130,8 @@ minetest.register_craftitem("mcl_fishing:fish_raw", { minetest.register_craftitem("mcl_fishing:fish_cooked", { description = "Cooked Fish", 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, groups = { food=2, eatable=5 }, }) @@ -145,7 +147,8 @@ minetest.register_craft({ minetest.register_craftitem("mcl_fishing:salmon_raw", { description = "Raw Salmon", 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, groups = { food=2, eatable = 2 }, }) @@ -153,7 +156,8 @@ minetest.register_craftitem("mcl_fishing:salmon_raw", { minetest.register_craftitem("mcl_fishing:salmon_cooked", { description = "Cooked Salmon", 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, groups = { food=2, eatable=6 }, }) @@ -169,7 +173,8 @@ minetest.register_craft({ minetest.register_craftitem("mcl_fishing:clownfish_raw", { description = "Clownfish", 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, groups = { food=2, eatable = 1 }, }) @@ -178,7 +183,8 @@ minetest.register_craftitem("mcl_fishing:clownfish_raw", { minetest.register_craftitem("mcl_fishing:pufferfish_raw", { description = "Pufferfish", 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, groups = { food=2, eatable=1 }, }) diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 9ec58cf45e..2def7a09a0 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -5,7 +5,8 @@ minetest.register_craftitem("mcl_mobitems:rotten_flesh", { inventory_image = "mcl_mobitems_rotten_flesh.png", wield_image = "mcl_mobitems_rotten_flesh.png", -- 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 }, stack_max = 64, }) @@ -14,7 +15,8 @@ minetest.register_craftitem("mcl_mobitems:mutton", { description = "Raw Mutton", inventory_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 }, stack_max = 64, }) @@ -23,7 +25,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_mutton", { description = "Cooked Mutton", inventory_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 }, stack_max = 64, }) @@ -32,7 +35,8 @@ minetest.register_craftitem("mcl_mobitems:beef", { description = "Raw Beef", inventory_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 }, stack_max = 64, }) @@ -41,7 +45,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_beef", { description = "Steak", inventory_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 }, stack_max = 64, }) @@ -50,7 +55,8 @@ minetest.register_craftitem("mcl_mobitems:chicken", { description = "Raw Chicken", inventory_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 }, stack_max = 64, }) @@ -59,7 +65,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_chicken", { description = "Cooked Chicken", inventory_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 }, stack_max = 64, }) @@ -68,7 +75,8 @@ minetest.register_craftitem("mcl_mobitems:porkchop", { description = "Raw Porkchop", inventory_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 }, stack_max = 64, }) @@ -77,7 +85,8 @@ minetest.register_craftitem("mcl_mobitems:cooked_porkchop", { description = "Cooked Porkchop", inventory_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 }, stack_max = 64, }) @@ -86,7 +95,8 @@ minetest.register_craftitem("mcl_mobitems:rabbit", { description = "Raw Rabbit", inventory_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 }, stack_max = 64, }) @@ -95,18 +105,19 @@ minetest.register_craftitem("mcl_mobitems:cooked_rabbit", { description = "Cooked Rabbit", inventory_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 }, stack_max = 64, }) --- TODO: Fix drinking sound -- TODO: Clear status effects minetest.register_craftitem("mcl_mobitems:milk_bucket", { description = "Milk", inventory_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, groups = { food = 3 }, }) @@ -115,7 +126,8 @@ minetest.register_craftitem("mcl_mobitems:spider_eye", { description = "Spider Eye", inventory_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 }, stack_max = 64, }) @@ -218,7 +230,8 @@ minetest.register_craftitem("mcl_mobitems:rabbit_stew", { wield_image = "mcl_mobitems_rabbit_stew.png", inventory_image = "mcl_mobitems_rabbit_stew.png", 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 }, })