Skip to content

Commit

Permalink
fix: add logic to check for 0 index
Browse files Browse the repository at this point in the history
with GetMacroIndexByName, if no macro exists, the index is 0, so no
macro was ever created because it had a value. Updated the logic to add
a check for 0. Also added new DebugLog addon integration for debugging
  • Loading branch information
lyledouglass committed Mar 19, 2024
1 parent 9ff647c commit 841208e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions HearthstoneRandomizer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RHT.to:SetScript("OnUpdate", function (self, elapse)
if RHTInitialized then
SetRandomHearthToy()
-- Debug output
-- print "HearthstoneRandomizer initialized"
if DLAPI then DLAPI.DebugLog("HearthstoneRandomizer","RHT Initialized") end
RHT.to:SetScript("OnUpdate", nil)
else
timeOut = 1
Expand Down Expand Up @@ -135,7 +135,10 @@ end
-- and it creates a new one.
function GetMacro()
macroExists = GetMacroIndexByName("RHT")
if macroExists then
if DLAPI then DLAPI.DebugLog("HearthstoneRandomizer","Macro index: " .. macroExists) end
if macroExists == 0 then
RHTIndex = false
else
RHTIndex = macroExists
end
end
Expand All @@ -145,11 +148,11 @@ function GenMacro(itemID, toyName)
if RHTIndex then
EditMacro(RHTIndex, "RHT", "INV_MISC_QUESTIONMARK", "#showtooltip item:" .. itemID .. "\r/cast " .. toyName)
-- Debug output
-- print "Macro updated"
if DLAPI then DLAPI.DebugLog("HearthstoneRandomizer","Macro updated") end
else
CreateMacro("RHT", "INV_MISC_QUESTIONMARK", "#showtooltip item:" .. itemID .. "\r/cast " .. toyName)
-- Debug output
-- print "Macro created"
if DLAPI then DLAPI.DebugLog("HearthstoneRandomizer","Macro created") end
GetMacro()
end
end
Expand Down

0 comments on commit 841208e

Please sign in to comment.