From 1835ab63d3db4e5a94c9f42590fa94337ee2a7ea Mon Sep 17 00:00:00 2001 From: Milan2018 Date: Sun, 10 Nov 2024 15:02:40 +0100 Subject: [PATCH] Update --- thirsty/interop_farming_redo.lua | 62 +++++++++++++++++--------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/thirsty/interop_farming_redo.lua b/thirsty/interop_farming_redo.lua index 66a4feb..dcea5c4 100644 --- a/thirsty/interop_farming_redo.lua +++ b/thirsty/interop_farming_redo.lua @@ -15,22 +15,25 @@ local E = thirsty.ext_nodes_items -------------------- -- Hydrate only -- -------------------- -local def = table.copy(minetest.registered_items["farming:glass_water"]) -def.on_use = function(itemstack,player,pointed_thing) - thirsty.drink(player,2,20,E.drinking_glass) - itemstack:take_item() - return itemstack - end -minetest.register_craftitem(":farming:glass_water", def) +if minetest.registered_items["farming:glass_water"] then + local def = table.copy(minetest.registered_items["farming:glass_water"]) + def.on_use = function(itemstack,player,pointed_thing) + thirsty.drink(player,2,20,E.drinking_glass) + itemstack:take_item() + return itemstack + end + minetest.register_craftitem(":farming:glass_water", def) +end - -local def = table.copy(minetest.registered_items["farming:rose_water"]) -def.on_use = function(itemstack,player,pointed_thing) - thirsty.drink(player,12,24,E.glass_bottle) - itemstack:take_item() - return itemstack - end -minetest.register_craftitem(":farming:rose_water", def) +if minetest.registered_items["farming:rose_water"] then + local def = table.copy(minetest.registered_items["farming:rose_water"]) + def.on_use = function(itemstack,player,pointed_thing) + thirsty.drink(player,12,24,E.glass_bottle) + itemstack:take_item() + return itemstack + end + minetest.register_craftitem(":farming:rose_water", def) +end ---------------------------- -- Hydrate and Food Items -- @@ -52,20 +55,21 @@ thirsty.register_food_drink("farming:chili_pepper" ,1,-1,-5,40,nil) -------------------- -- Complex/Custom -- -------------------- -local def = table.copy(minetest.registered_items["farming:cactus_juice"]) -def.on_use = function(itemstack, player, pointed_thing) - if player then - if math.random(5) == 1 then - thirsty.drink(player,-2,20,E.drinking_glass) - itemstack:take_item() - return itemstack - else - thirsty.drink(player,6,20,E.drinking_glass) - itemstack:take_item() - return itemstack +if minetest.registered_items["farming:cactus_juice"] then + local def = table.copy(minetest.registered_items["farming:cactus_juice"]) + def.on_use = function(itemstack, player, pointed_thing) + if player then + if math.random(5) == 1 then + thirsty.drink(player,-2,20,E.drinking_glass) + itemstack:take_item() + return itemstack + else + thirsty.drink(player,6,20,E.drinking_glass) + itemstack:take_item() + return itemstack + end end end - end -minetest.register_craftitem(":farming:cactus_juice", def) - + minetest.register_craftitem(":farming:cactus_juice", def) +end