From 7cd75058012c561d5dd0c96926f36ed731e4b02d Mon Sep 17 00:00:00 2001 From: fuba Date: Mon, 10 Jun 2024 20:51:53 +0200 Subject: [PATCH] Macro is now created even if there is no "Mage Food" in your Inventory with "Conjured Mana Biscuit" as default item! --- Core.lua | 64 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 26 deletions(-) diff --git a/Core.lua b/Core.lua index 4f61b1c..4cbf08d 100644 --- a/Core.lua +++ b/Core.lua @@ -70,7 +70,8 @@ local MageFoodIDs = { 65499, --Conjured Mana Cake 43523, --Conjured Mana Strudel 43518, --Conjured Mana Pie - 34062 --Conjured Mana Biscuit + 34062, --Conjured Mana Biscuit + --5349 --Conjured Muffin } local function CreateOrUpdateMacro() @@ -80,35 +81,46 @@ local function CreateOrUpdateMacro() end BestMageFoodInBag = BestMageFoodInBag or 0 - --if GetItemCount(BestMageFoodInBag) > 0 then return end - - for _,v in ipairs(MageFoodIDs) do - if GetItemCount(v) > 0 then - BestMageFoodInBag = v - break - end - end - if BestMageFoodInBag == 0 then return end - + local macroName = (fubaMageFoodMacroDB and fubaMageFoodMacroDB.options and fubaMageFoodMacroDB.options.macroName) or DefaultSettings.options.macroName local conjureOnRightClick = (fubaMageFoodMacroDB and fubaMageFoodMacroDB.options and fubaMageFoodMacroDB.options.conjureOnRightClick) or DefaultSettings.options.conjureOnRightClick local MacroIndex = GetMacroIndexByName(macroName); + local macroId = 0; + + if (MacroIndex == 0) then -- Use "Conjured Mana Biscuit" by default if there is not Mage Item in inventoery + local macroln1 = ""; + local macroln2 = ""; + local itemUseString = "item:34062" -- use Item by ID (Conjured Mana Biscuit) + + macroln1 = "#showtooltip "..itemUseString.."\n"; + if conjureOnRightClick then + macroln2 = "/use [btn:2]"..spellNameConjureRefreshment..";"..itemUseString.."\n"; + else + macroln2 = "/use "..itemUseString.."\n"; + end + + macroId = CreateMacro(macroName, "INV_MISC_QUESTIONMARK", macroln1..macroln2, nil) + else + for _,v in ipairs(MageFoodIDs) do + if GetItemCount(v) > 0 then + BestMageFoodInBag = v + break + end + end + if BestMageFoodInBag == 0 then return end + + local macroln1 = ""; + local macroln2 = ""; + local itemUseString = "item:"..BestMageFoodInBag + + macroln1 = "#showtooltip "..itemUseString.."\n"; + if conjureOnRightClick then + macroln2 = "/use [btn:2]"..spellNameConjureRefreshment..";"..itemUseString.."\n"; + else + macroln2 = "/use "..itemUseString.."\n"; + end - local macroln1 = ""; - local macroln2 = ""; - local itemUseString = "item:"..BestMageFoodInBag - - macroln1 = "#showtooltip "..itemUseString.."\n"; - if conjureOnRightClick then - macroln2 = "/use [btn:2]"..spellNameConjureRefreshment..";"..itemUseString.."\n"; - else - macroln2 = "/use "..itemUseString.."\n"; - end - - if (MacroIndex == 0) then - local macroId = CreateMacro(macroName, "INV_MISC_QUESTIONMARK", macroln1..macroln2, nil) - else - local macroId = EditMacro(MacroIndex, macroName, "INV_MISC_QUESTIONMARK", macroln1..macroln2) + macroId = EditMacro(MacroIndex, macroName, "INV_MISC_QUESTIONMARK", macroln1..macroln2) end end