reportHits and reportSwings minor bug fix

Created a fail safe to check if required field for reporting existed and if it did not, create a default to print error.
master
icecool 6 years ago
parent b00898e739
commit 1460902eb4

@ -28,7 +28,7 @@
<script>
<![CDATA[
--[[ External Resources ]]--
dofile(GetInfo(60) .. "aardwolf_colors.lua") -- Used to support Aard Colors for the eprint() function
dofile(GetInfo(60) .. "aardwolf_colors.lua") -- Used to support Aard Colors for the cnote() function
-- Basic print function that supports aard, xterm, and ANSI color codes [idea from Durel's Inventory script]
Debug = false
function cnote(string)
@ -152,8 +152,8 @@ function TRIGGER_process_hits_line(_, line, _, _)
end
function returnPercent( instinct, total )
if (tonumber(instinct) or tonumber(total)) == nil then
print( "[ERROR]: Cannot caluclate a percentage on the items provided." )
return 0
dnote( "returnPercent() cannot caluclate a percentage on the items provided." )
return 0
end
return (("%0.2f"):format(tonumber(instinct)/tonumber(total)*100))
end
@ -162,6 +162,14 @@ function returnTotalInstinctHits()
end
--[[ create report ]]--
function reportSwings()
-- Check to see if swing number was reported, if not make the entry = 0
for _, hit in pairs(dtrack_track) do
if not tonumber(dtrack.regular[hit]) then
dnote(("reportSwings() - %s was reported as not a number. Setting it to 0."):format(hit))
dtrack.regular[hit] = 0
end
end
local message = ("%s %s Swings/Round[%0.2f] Hits%%[%0.2f] DPH[%0.2f]"):format(
dtrack.channel,
dtrack.regular.prepend,
@ -170,7 +178,6 @@ function reportSwings()
dtrack.regular.dph)
dnote( message )
if dtrack.regular.sname then
if tonumber(dtrack.regular.trackedavg) == nil then dtrack.regular.trackedavg = 0 end
message = ("%s %s(%0.2f)"):format(message, dtrack.regular.sname, dtrack.regular.trackedavg)
dnote( message )
end
@ -178,8 +185,14 @@ function reportSwings()
dtrack.regular = nil
end
function reportHits()
local command = ("%s %s %s(%d) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d) %s(%d) %s(%d/%d [%0.2f%%]) %s(%d) | Total Hits(%d/%d [%0.2f%%])"):format( dtrack.channel,
dtrack.hits.prepend, "Primary Attack", dtrack.hits["Primary Attack"], "Second Attack", dtrack.hits["Second Attack"], dtrack.hits["inst_Second Attack"], returnPercent(dtrack.hits["inst_Second Attack"], dtrack.hits["Hits"] ), "Third Attack", dtrack.hits["Third Attack"], dtrack.hits["inst_Third Attack"], returnPercent(dtrack.hits["inst_Third Attack"], dtrack.hits["Hits"] ), "Fourth Attack", dtrack.hits["Fourth Attack"], dtrack.hits["inst_Fourth Attack"], returnPercent(dtrack.hits["inst_Fourth Attack"], dtrack.hits["Hits"] ), "Dual Wield", dtrack.hits["Dual Wield"], dtrack.hits["inst_Dual Wield"], returnPercent(dtrack.hits["inst_Dual Wield"], dtrack.hits["Hits"] ), "Second Dual", dtrack.hits["Second Dual"], "Third Dual", dtrack.hits["Third Dual"], "Haste Attacks", dtrack.hits["Haste Attacks"], dtrack.hits["inst_Haste Attacks"], returnPercent(dtrack.hits["inst_Haste Attacks"], dtrack.hits["Hits"] ), "Lightspeed", dtrack.hits["Lightspeed"], dtrack.hits["Hits"], returnTotalInstinctHits(), returnPercent(returnTotalInstinctHits(), dtrack.hits["Hits"]) )
-- Check to see if instinct was reported, if not make the entry = 0
if not tonumber(dtrack.hits["inst_Second Attack"]) then dtrack.hits["inst_Second Attack"] = 0 end
if not tonumber(dtrack.hits["inst_Third Attack"]) then dtrack.hits["inst_Third Attack"] = 0 end
if not tonumber(dtrack.hits["inst_Fourth Attack"]) then dtrack.hits["inst_Fourth Attack"] = 0 end
if not tonumber(dtrack.hits["inst_Dual Wield"]) then dtrack.hits["inst_Dual Wield"] = 0 end
if not tonumber(dtrack.hits["inst_Haste Attacks"]) then dtrack.hits["inst_Haste Attacks"] = 0 end
-- Build command for SendNoEcho()
local command = ("%s %s %s(%d) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d/%d [%0.2f%%]) %s(%d) %s(%d) %s(%d/%d [%0.2f%%]) %s(%d) | Total Hits(%d/%d [%0.2f%%])"):format( dtrack.channel, dtrack.hits.prepend, "Primary Attack", dtrack.hits["Primary Attack"], "Second Attack", dtrack.hits["Second Attack"], dtrack.hits["inst_Second Attack"], returnPercent(dtrack.hits["inst_Second Attack"], dtrack.hits["Hits"] ), "Third Attack", dtrack.hits["Third Attack"], dtrack.hits["inst_Third Attack"], returnPercent(dtrack.hits["inst_Third Attack"], dtrack.hits["Hits"] ), "Fourth Attack", dtrack.hits["Fourth Attack"], dtrack.hits["inst_Fourth Attack"], returnPercent(dtrack.hits["inst_Fourth Attack"], dtrack.hits["Hits"] ), "Dual Wield", dtrack.hits["Dual Wield"], dtrack.hits["inst_Dual Wield"], returnPercent(dtrack.hits["inst_Dual Wield"], dtrack.hits["Hits"] ), "Second Dual", dtrack.hits["Second Dual"], "Third Dual", dtrack.hits["Third Dual"], "Haste Attacks", dtrack.hits["Haste Attacks"], dtrack.hits["inst_Haste Attacks"], returnPercent(dtrack.hits["inst_Haste Attacks"], dtrack.hits["Hits"] ), "Lightspeed", dtrack.hits["Lightspeed"], dtrack.hits["Hits"], returnTotalInstinctHits(), returnPercent(returnTotalInstinctHits(), dtrack.hits["Hits"]) )
SendNoEcho( command )
dtrack.hits = nil
end

Loading…
Cancel
Save