Skip to content

Commit

Permalink
create default macro when mega macro is not in use (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
phuze authored Oct 25, 2024
1 parent e01fbc6 commit 3694135
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ local function UpdateMegaMacro(newCode)
return
end
end
print("|cffff0000AutoPotion Error:|r Missing global 'AutoPotion' macro in MegaMacro. Please create it.")
print("|cffff0000AutoPotion Error:|r Missing global 'AutoPotion' macro in MegaMacro. Please create it then reload your game.")
end

local function checkMegaMacroAddon()
Expand All @@ -200,6 +200,8 @@ local function checkMegaMacroAddon()
return
end

megaMacro.installed = true

-- is the addon loaded?
if C_AddOns.IsAddOnLoaded(megaMacro.name) then
megaMacro.loaded = true
Expand Down Expand Up @@ -244,15 +246,17 @@ function ham.updateMacro()

if megaMacro.installed and megaMacro.loaded then
UpdateMegaMacro(macroStr)
else
createMacroIfMissing()
EditMacro(macroName, macroName, nil, macroStr)
return
end

log('MegaMacro not in use. Creating default macro.')
createMacroIfMissing()
EditMacro(macroName, macroName, nil, macroStr)
end

local function MakeMacro()
-- dont attempt to create macro until MegaMacro addon is checked
if not megaMacro.checked or (megaMacro.checked and megaMacro.installed and not megaMacro.loaded) then
if not megaMacro.checked then
log("MegaMacro not checked or loaded. Retrying.")
checkMegaMacroAddon()
return
Expand Down Expand Up @@ -298,15 +302,15 @@ updateFrame:SetScript("OnEvent", function(self, event, arg1, ...)
-- bag update events
if event == "BAG_UPDATE" then
onBagUpdate()
-- on loading/reloading
-- on loading/reloading
elseif event == "PLAYER_ENTERING_WORLD" then
log("event: PLAYER_ENTERING_WORLD")
MakeMacro()
-- on exiting combat
-- on exiting combat
elseif event == "PLAYER_REGEN_ENABLED" then
log("event: PLAYER_REGEN_ENABLED")
MakeMacro()
-- when talents change and classic is false
-- when talents change and classic is false
elseif isClassic == false and event == "TRAIT_CONFIG_UPDATED" then
log("event: TRAIT_CONFIG_UPDATED")
MakeMacro()
Expand Down

0 comments on commit 3694135

Please sign in to comment.