Damage Counter script errors

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Still cant find the problem...


if not CritCounter then
CritCounter = {
_totalHits = 0,
_loaded = false,
_enabled = true,
}

local cc = CritCounter

display("Loading Crit Table")
cc._critTable = {}
cc._critTable["pathetic"] = 0
cc._critTable["weak"] = 0
cc._critTable["punishing"] = 0
cc._critTable["surprising"] = 0
cc._critTable["amazing"] = 0
cc._critTable["astonishing"] = 0
cc._critTable["mauling"] = 0
cc._critTable["decimating"] = 0
cc._critTable["devastating"] = 0
cc._critTable["pulverizing"] = 0
cc._critTable["maiming"] = 0
cc._critTable["eviscerating"] = 0
cc._critTable["mutilating"] = 0
cc._critTable["disemboweling"] = 0
cc._critTable["dismembering"] = 0
cc._critTable["massacring"] = 0
cc._critTable["mangling"] = 0
cc._critTable["demolishing"] = 0
cc._critTable["obliterating"] = 0
cc._critTable["annihilating"] = 0
cc._critTable["eradicating"] = 0
cc._critTable["vaporizing"] = 0
cc._critTable["destructive"] = 0
cc._critTable["extreme"] = 0
cc._critTable["porcine"] = 0
cc._critTable["divine"] = 0
cc._critTable["daunting"] = 0
cc._critTable["terminal"] = 0

cc._critLast = {}
cc._critLast["pathetic"] = 0
cc._critLast["weak"] = 0
cc._critLast["punishing"] = 0
cc._critLast["surprising"] = 0
cc._critLast["amazing"] = 0
cc._critLast["astonishing"] = 0
cc._critLast["mauling"] = 0
cc._critLast["decimating"] = 0
cc._critLast["devastating"] = 0
cc._critLast["pulverizing"] = 0
cc._critLast["maiming"] = 0
cc._critLast["eviscerating"] = 0
cc._critLast["mutilating"] = 0
cc._critLast["disemboweling"] = 0
cc._critLast["dismembering"] = 0
cc._critLast["massacring"] = 0
cc._critLast["mangling"] = 0
cc._critLast["demolishing"] = 0
cc._critLast["obliterating"] = 0
cc._critLast["annihilating"] = 0
cc._critLast["eradicating"] = 0
cc._critLast["vaporizing"] = 0
cc._critLast["destructive"] = 0
cc._critLast["extreme"] = 0
cc._critLast["porcine"] = 0
cc._critLast["divine"] = 0
cc._critLast["daunting"] = 0
cc._critLast["terminal"] = 0


cc._critDisplayOrder = { "pathetic" , "weak" , "punishing" , "surprising" , "amazing" , "astonishing" ,
"mauling" , "decimating" , "devastating" , "pulverizing" , "maiming" ,
"eviscerating" , "mutilating" , "disemboweling" , "dismembering" ,
"massacring" , "mangling" , "demolishing" , "obliterating" , "annihilating" ,
"eradicating" , "vaporizing" , "destructive" , "extreme" , "porcine" ,
"divine" , "daunting" , "terminal" }
cc._critNames = {}
cc._critNames["pathetic"] = "pathetic"
cc._critNames["weak"] = "weak"
cc._critNames["punishing"] = "punishing"
cc._critNames["surprising"] = "surprising"
cc._critNames["amazing"] = "amazing"
cc._critNames["astonishing"] = "astonishing"
cc._critNames["mauling MAULING MAULING* MAULING** MAULING***"] = "mauling"
cc._critNames["decimating DECIMATING DECIMATING* DECIMATING** DECIMATING***"] = "decimating"
cc._critNames["devastating DEVASTATING DEVASTATING* DEVASTATING** DEVASTATING***"] = "devastating"
cc._critNames["pulverizing PULVERIZING PULVERIZING* PULVERIZING** PULVERIZING***"] = "pulverizing"
cc._critNames["maiming MAIMING MAIMING* MAIMING** MAIMING***"] = "maiming"
cc._critNames["eviscerating EVISCERATING EVISCERATING* EVISCERATING** EVISCERATING***"] = "eviscerating"
cc._critNames["mutilating MUTILATING MUTILATING* MUTILATING** MUTILATING***"] = "mutilating"
cc._critNames["disemboweling DISEMBOWELING DISEMBOWELING* DISEMBOWELING** DISEMBOWELING***"] = "disemboweling"
cc._critNames["dismembering DISMEMBERING DISMEMBERING* DISMEMBERING** DISMEMBERING***"] = "dismembering"
cc._critNames["massacring MASSACRING MASSACRING* MASSACRING** MASSACRING***"] = "massacring"
cc._critNames["mangling MANGLING MANGLING* MANGLING** MANGLING***"] = "mangling"
cc._critNames["demolishing DEMOLISHING DEMOLISHING* DEMOLISHING** DEMOLISHING***"] = "demolishing"
cc._critNames["obliterating OBLITERATING OBLITERATING* OBLITERATING** OBLITERATING***"] = "obliterating"
cc._critNames["annihilating ANNIHILATING ANNIHILATING* ANNIHILATING** ANNIHILATING*** ANNIHILATING***< ANNIHILATING***<< ANNIHILATING***<<< ANNIHILATING***<<<<"] = "annihilating"
cc._critNames["eradicating ERADICATING ERADICATING* ERADICATING** ERADICATING*** ERADICATING***< ERADICATING***<< ERADICATING***<<< ERADICATING***<<<<"] = "eradicating"
cc._critNames["vaporizing VAPORIZING VAPORIZING* VAPORIZING** VAPORIZING*** VAPORIZING***< VAPORIZING***<< VAPORIZING***<<< VAPORIZING***<<<<"] = "vaporizing"
cc._critNames["destructive DESTRUCTIVE DESTRUCTIVE* DESTRUCTIVE** DESTRUCTIVE*** DESTRUCTIVE**** DESTRUCTIVE****< DESTRUCTIVE****<< DESTRUCTIVE****<<< DESTRUCTIVE****<<<< DESTRUCTIVE***<<<<= DESTRUCTIVE**<<<<== DESTRUCTIVE*<<<<=== DESTRUCTIVE<<<<===="] = "destructive"
cc._critNames["extreme EXTREME EXTREME* EXTREME** EXTREME*** EXTREME**** EXTREME****< EXTREME****<< EXTREME****<<< EXTREME****<<<< EXTREME***<<<<= EXTREME**<<<<== EXTREME*<<<<=== EXTREME<<<<===="] = "extreme"
cc._critNames["porcine PORCINE PORCINE* PORCINE** PORCINE*** PORCINE***< PORCINE***<< PORCINE***<<< PORCINE***<<<<"] = "porcine"
cc._critNames["divine"] = "divine"
cc._critNames["daunting"] = "daunting"
cc._critNames["terminal"] = "terminal"
end

function CritCounter:Enable(enable)
self._enabled = enable
cecho("\n<light_grey>[ <yellow>DAMAGE REPORT <light_grey>]: Counter has been ")
if enable then cecho("<light_grey>enabled!")
else cecho("<light_grey>disabled!") end
echo("\n")
end


function CritCounter:Load(force)
if self._loaded and not force then return end

local loadTable = {}

if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else _sep = "\\" end

local l_SettingsFile = getMudletHomeDir() .. _sep .. "CritCounter.lua"

if (io.exists(l_SettingsFile)) then
table.load(l_SettingsFile, loadTable)
end

if not loadTable.critTable or not loadTable.totalHits or not loadTable.critLast then
cecho("<red>Failed to load DAMAGE REPORT saved data!")
cecho("<white>Ignore this warning if you have just")
cecho("<white> installed the counter")
return
end

self._critTable = loadTable.critTable
self._totalHits = loadTable.totalHits
self._critLast = loadTable.critLast

self._loaded = true
end

function CritCounter:Save()
if string.char(getMudletHomeDir():byte()) == "/" then _sep = "/" else _sep = "\\" end
local l_SettingsFile = getMudletHomeDir() .. _sep .. "CritCounter.lua"

local savetable = {}

savetable.critTable = self._critTable
savetable.totalHits = self._totalHits
savetable.critLast = self._critLast

table.save(l_SettingsFile, savetable)
end

function CritCounter:display()
local totalcrits = 0
for _, num in pairs(self._critTable) do
totalcrits = totalcrits + num
end

local critrate = self._totalHits == 0 and 0 or (totalcrits / self._totalHits) * 100

cecho("\n<grey>" .. string.rep("-", 31) .. "[ <yellow>DAMAGE REPORT:<grey> ]" .. string.rep("-", 31) .. "\n\n")
cecho("<RoyalBlue>Total hits: <white>" .. self._totalHits .. "\n")
cecho("<RoyalBlue>Total crits: <white>" .. totalcrits .. "\n")
cecho("<RoyalBlue>Total crit-rate: <white>" .. string.format("%.3f", critrate) .. "\n")

cecho("\n\n<DarkGreen>Statistics:\n")
for _, crit in ipairs(self._critDisplayOrder) do
local rate = totalcrits == 0 and 0.0 or (self._critTable[crit] / totalcrits) * 100

if not crit then print("NIL VARIABLE: crit") end
if not self._critTable[crit] then
print("NIL VARIABLE: self._critTable[crit]")
display(crit)
display(self._critTable)
end
if not rate then print("NIL VARIABLE: rate") end
if not self._critLast[crit] then print("NIL VARIABLE: self._critLast[crit]") end

local format_str = "<light_goldenrod_yellow>%-20s<white>%s <LimeGreen>[ %-8.3f ] - %s hits ago!\n"
local line = string.format(format_str,crit,self._critTable[crit],rate,self._critLast[crit])

cecho(line)
end
cecho("\n<grey>" .. string.rep("-", 80) .. "\n")
end

function CritCounter:Reset()
for crit, _ in pairs(self._critTable) do
self._critTable[crit] = 0
self._critLast[crit] = 0
end

self._totalHits = 0

self:Save()

cecho("\n<light_grey>[ <yellow>DAMAGE REPORT <light_grey>]: Counter has been reset!")
end

function CritCounter:AddHit()
if not self._enabled then return end

self._totalHits = self._totalHits + 1
for crit, _ in pairs(self._critLast) do
self._critLast[crit] = self._critLast[crit] + 1
end

end

function CritCounter:AddCrit(type)
if not self._enabled or not type then return end

type = self._critNames[type]

self._critTable[type] = self._critTable[type] + 1
self._critLast[type] = 0

self:Save()
end

CritCounter:Load()

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Damage Counter script errors

Post by Vadi »

Try contacting the original script author for help?

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Damage Counter script errors

Post by Jor'Mox »

This
Code: [show] | [select all] lua
local l_SettingsFile = getMudletHomeDir() .. _sep .. "CritCounter.lua
looks like it is for loading an external file, which could easily overwrite your code.

Now, the problem isn't so much finding the file, but finding where it is getting loaded.

Jor'Mox
Posts: 1142
Joined: Wed Apr 03, 2013 2:19 am

Re: Damage Counter script errors

Post by Jor'Mox »

Also, I wrote an addition to the declarations portion of your script that might help out. Basically I just added a for loop after your if statement that adds in any missing values in the _critTable and _critLast tables.
Code: [show] | [select all] lua
if not CritCounter then
	display("Loading Crit Table")
	CritCounter = {
		_totalHits = 0,
		_loaded = false,
		_enabled = true,
		}

	local cc = CritCounter

	cc._critDisplayOrder = {
		"pathetic", "weak", "punishing", "surprising",
		"amazing", "astonishing", "mauling", "decimating",
		"devastating", "pulverizing", "maiming", "eviscerating",
		"mutilating", "disemboweling", "dismembering", "massacring",
		"mangling", "demolishing", "obliterating", "annihilating",
		"eradicating", "vaporizing", "destructive", "extreme",
		"porcine", "divine", "daunting", "terminal",
		}
	cc._critTable = {
		pathetic = 0, weak = 0, punishing = 0, suprising = 0,
		amazing = 0, astonishing = 0, mauling = 0, decimating = 0,
		devastating = 0, pulverizing = 0, maiming = 0, eviscerating = 0,
		mutilating = 0, disemboweling = 0, dismembering = 0, massacring = 0,
		mangling = 0, demolishing = 0, obliterating = 0, annihilating = 0,
		eradicating = 0, vaporizing = 0, destructive = 0, extreme = 0,
		porcine = 0, divine = 0, daunting = 0, terminal = 0,
		}
	cc._critLast = {
		pathetic = 0, weak = 0, punishing = 0, suprising = 0,
		amazing = 0, astonishing = 0, mauling = 0, decimating = 0,
		devastating = 0, pulverizing = 0, maiming = 0, eviscerating = 0,
		mutilating = 0, disemboweling = 0, dismembering = 0, massacring = 0,
		mangling = 0, demolishing = 0, obliterating = 0, annihilating = 0,
		eradicating = 0, vaporizing = 0, destructive = 0, extreme = 0,
		porcine = 0, divine = 0, daunting = 0, terminal = 0,
		}
	cc._critNames = {}
	cc._critNames["pathetic"] = "pathetic"
	cc._critNames["weak"] = "weak"
	cc._critNames["punishing"] = "punishing"
	cc._critNames["surprising"] = "surprising"
	cc._critNames["amazing"] = "amazing"
	cc._critNames["astonishing"] = "astonishing"
	cc._critNames["mauling MAULING MAULING* MAULING** MAULING***"] = "mauling"
	cc._critNames["decimating DECIMATING DECIMATING* DECIMATING** DECIMATING***"] = "decimating"
	cc._critNames["devastating DEVASTATING DEVASTATING* DEVASTATING** DEVASTATING***"] = "devastating"
	cc._critNames["pulverizing PULVERIZING PULVERIZING* PULVERIZING** PULVERIZING***"] = "pulverizing"
	cc._critNames["maiming MAIMING MAIMING* MAIMING** MAIMING***"] = "maiming"
	cc._critNames["eviscerating EVISCERATING EVISCERATING* EVISCERATING** EVISCERATING***"] = "eviscerating"
	cc._critNames["mutilating MUTILATING MUTILATING* MUTILATING** MUTILATING***"] = "mutilating"
	cc._critNames["disemboweling DISEMBOWELING DISEMBOWELING* DISEMBOWELING** DISEMBOWELING***"] = "disemboweling"
	cc._critNames["dismembering DISMEMBERING DISMEMBERING* DISMEMBERING** DISMEMBERING***"] = "dismembering"
	cc._critNames["massacring MASSACRING MASSACRING* MASSACRING** MASSACRING***"] = "massacring"
	cc._critNames["mangling MANGLING MANGLING* MANGLING** MANGLING***"] = "mangling"
	cc._critNames["demolishing DEMOLISHING DEMOLISHING* DEMOLISHING** DEMOLISHING***"] = "demolishing"
	cc._critNames["obliterating OBLITERATING OBLITERATING* OBLITERATING** OBLITERATING***"] = "obliterating"
	cc._critNames["annihilating ANNIHILATING ANNIHILATING* ANNIHILATING** ANNIHILATING*** ANNIHILATING***< ANNIHILATING***<< ANNIHILATING***<<< ANNIHILATING***<<<<"] = "annihilating"
	cc._critNames["eradicating ERADICATING ERADICATING* ERADICATING** ERADICATING*** ERADICATING***< ERADICATING***<< ERADICATING***<<< ERADICATING***<<<<"] = "eradicating"
	cc._critNames["vaporizing VAPORIZING VAPORIZING* VAPORIZING** VAPORIZING*** VAPORIZING***< VAPORIZING***<< VAPORIZING***<<< VAPORIZING***<<<<"] = "vaporizing"
	cc._critNames["destructive DESTRUCTIVE DESTRUCTIVE* DESTRUCTIVE** DESTRUCTIVE*** DESTRUCTIVE**** DESTRUCTIVE****< DESTRUCTIVE****<< DESTRUCTIVE****<<< DESTRUCTIVE****<<<< DESTRUCTIVE***<<<<= DESTRUCTIVE**<<<<== DESTRUCTIVE*<<<<=== DESTRUCTIVE<<<<===="] = "destructive"
	cc._critNames["extreme EXTREME EXTREME* EXTREME** EXTREME*** EXTREME**** EXTREME****< EXTREME****<< EXTREME****<<< EXTREME****<<<< EXTREME***<<<<= EXTREME**<<<<== EXTREME*<<<<=== EXTREME<<<<===="] = "extreme"
	cc._critNames["porcine PORCINE PORCINE* PORCINE** PORCINE*** PORCINE***< PORCINE***<< PORCINE***<<< PORCINE***<<<<"] = "porcine"
	cc._critNames["divine"] = "divine"
	cc._critNames["daunting"] = "daunting"
	cc._critNames["terminal"] = "terminal"
end

for k,v in ipairs(CritCounter._critDisplayOrder) do
	CritCounter._critTable[v] = CritCounter._critTable[v] or 0
	CritCounter._critLast[v] = CritCounter._critLast[v] or 0
end

User avatar
Akaya
Posts: 414
Joined: Thu Apr 19, 2012 1:36 am

Re: Damage Counter script errors

Post by Akaya »

It seems you are using the Achaean Crit Counter found here: http://forums.mudlet.org/viewtopic.php? ... nter#p4935

I'm guessing the problem is that you've altered the script (all the extra critical hit types) without first understanding how the original script works. Like Vadi stated, get in touch with the script's creator, Wyd (or at least that's who posted first).

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Jor'Mox your script worked, it showed the list of all damages. However when i ran and it doesnt tally at all.

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

The owner of script yet to reply... Am baffled here on why it is NOT firing. Thanks

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Damage Counter script errors

Post by Wyd »

Hi Nobelestone,

Sorry I haven't replied - its been quite a while since I've played (and longer still since I wrote that script).

What you might want to try and do is go to your mudlet profile directory, and delete the CritCounter.lua file you find there.

That gets loaded in each time you start up mudlet, and loads in your saved crit data - but since you've changed the _critTable table, its overriding your changes, and breaking things.

Try closing Mudlet, deleting that file), and reopening it again. You should see a "Failed to load CritCounter saved data! Ignore this warning if you have just installed the counter" error, since you deleted the old saved data.

After that, it should work fine, unless there is something else wrong I can't see.

Regards,

noblestone
Posts: 154
Joined: Sun Jul 29, 2012 6:50 am

Re: Damage Counter script errors

Post by noblestone »

Tried that just now, I didnt get Failed to load CritCounter saved data! All i get is this:

Total hits: 0
Total crits: 0
Total crit-rate: 0.000


Statistics:
pathetic 0 [ 0.000 ] - 0 hits ago!
weak 0 [ 0.000 ] - 0 hits ago!
punishing 0 [ 0.000 ] - 0 hits ago!
NIL VARIABLE: self._critTable[crit]
"surprising"

{
pathetic = 0,
suprising = 0,
astonishing = 0,
disemboweling = 0,
mauling = 0,
amazing = 0,
divine = 0,
mangling = 0,
annihilating = 0,
massacring = 0,
mutilating = 0,
terminal = 0,
daunting = 0,
dismembering = 0,
punishing = 0,
pulverizing = 0,
porcine = 0,
extreme = 0,
destructive = 0,
maiming = 0,
eviscerating = 0,
weak = 0,
demolishing = 0,
eradicating = 0,
obliterating = 0,
vaporizing = 0,
devastating = 0,
decimating = 0
}
NIL VARIABLE: self._critLast[crit]

Wyd
Posts: 54
Joined: Wed Mar 24, 2010 11:56 pm

Re: Damage Counter script errors

Post by Wyd »

Looks like you spelt surprising wrong in there somewhere.. If you can find that, it should work l

Post Reply