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> <script>
<![CDATA[ <![CDATA[
--[[ External Resources ]]-- --[[ 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] -- Basic print function that supports aard, xterm, and ANSI color codes [idea from Durel's Inventory script]
Debug = false Debug = false
function cnote(string) function cnote(string)
@ -152,7 +152,7 @@ function TRIGGER_process_hits_line(_, line, _, _)
end end
function returnPercent( instinct, total ) function returnPercent( instinct, total )
if (tonumber(instinct) or tonumber(total)) == nil then if (tonumber(instinct) or tonumber(total)) == nil then
print( "[ERROR]: Cannot caluclate a percentage on the items provided." ) dnote( "returnPercent() cannot caluclate a percentage on the items provided." )
return 0 return 0
end end
return (("%0.2f"):format(tonumber(instinct)/tonumber(total)*100)) return (("%0.2f"):format(tonumber(instinct)/tonumber(total)*100))
@ -162,6 +162,14 @@ function returnTotalInstinctHits()
end end
--[[ create report ]]-- --[[ create report ]]--
function reportSwings() 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( local message = ("%s %s Swings/Round[%0.2f] Hits%%[%0.2f] DPH[%0.2f]"):format(
dtrack.channel, dtrack.channel,
dtrack.regular.prepend, dtrack.regular.prepend,
@ -170,7 +178,6 @@ function reportSwings()
dtrack.regular.dph) dtrack.regular.dph)
dnote( message ) dnote( message )
if dtrack.regular.sname then 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) message = ("%s %s(%0.2f)"):format(message, dtrack.regular.sname, dtrack.regular.trackedavg)
dnote( message ) dnote( message )
end end
@ -178,8 +185,14 @@ function reportSwings()
dtrack.regular = nil dtrack.regular = nil
end end
function reportHits() 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, -- Check to see if instinct was reported, if not make the entry = 0
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"]) ) 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 ) SendNoEcho( command )
dtrack.hits = nil dtrack.hits = nil
end end

Loading…
Cancel
Save