From 9024c8084d5379f1264bb8747d98d94b2f8c4566 Mon Sep 17 00:00:00 2001 From: Brandon Date: Sat, 8 Aug 2020 17:48:03 -0400 Subject: [PATCH] Update how "on_use" is defined for potions. --- mods/ITEMS/mcl_potions/potions.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index b7608bd8c4..b9e0d253a0 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -54,13 +54,19 @@ local function register_potion(def) dur = 45 end - local on_use = function (itemstack, user, pointed_thing) - if not def.on_use then return end - def.on_use(user, def.effect, dur) - minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) - mcl_potions._use_potion(itemstack, user, def.color) - return itemstack + local on_use = nil + + if def.on_use then + + on_use = function (itemstack, user, pointed_thing) + + def.on_use(user, def.effect, dur) + minetest.do_item_eat(0, "mcl_potions:glass_bottle", itemstack, user, pointed_thing) + mcl_potions._use_potion(itemstack, user, def.color) + + return itemstack end + end local function get_tt(tt, effect, dur) local _tt