Skip to content

Commit

Permalink
create macro is not exisiting
Browse files Browse the repository at this point in the history
  • Loading branch information
ollidiemaus committed Dec 23, 2022
1 parent 3bffeb6 commit 50d0473
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion HealthstoneAutoMacro.toc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Interface: 100002
## Version: 2.5.2
## Version: 2.5.3
## Title: Healthstone Auto Macro
## Author: ollidiemaus
## Notes: Updates the Macro HAMHealthPot to use either Healthstone or the highest Potion found in Bags
Expand Down
15 changes: 12 additions & 3 deletions code.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local addonName, ham = ...
local macroName = "HAMHealthPot"

local function addPlayerHealingSpellsIfAvailable()
local myPlayer=ham.Player.new()
Expand Down Expand Up @@ -58,6 +59,13 @@ local function updateAvailableHeals()
addPotIfAvailable()
end

local function createMacroIfMissing()
local name = GetMacroInfo(macroName)
if name==nil then
CreateMacro(macroName,"INV_Misc_QuestionMark")
end
end

local function updateMacro()
local resetType = "combat"
local itemsString = ""
Expand All @@ -84,9 +92,10 @@ local function updateMacro()
ham.macroStr = ham.macroStr .. itemsString
end
end
EditMacro("HAMHealthPot", "HAMHealthPot", nil, ham.macroStr)
createMacroIfMissing()
EditMacro(macroName, macroName, nil, ham.macroStr)
end

local onCombat = true
local HealPotMacroIcon = CreateFrame("Frame")
HealPotMacroIcon:RegisterEvent("BAG_UPDATE")
Expand All @@ -105,7 +114,7 @@ HealPotMacroIcon:SetScript("OnEvent",function(self,event,...)
if event=="PLAYER_REGEN_ENABLED" then
onCombat = false
end

if onCombat==false then
updateAvailableHeals()
updateMacro()
Expand Down

0 comments on commit 50d0473

Please sign in to comment.