Your attacks strike A zombie 2 times, with *DISMEMBERING* viciousness!
Your attacks strike A zombie 5 times, with demolishing ferocity!
Your attacks strike A half-decomposed zombie 3 times, with **MASSACRING** passion!
LUA: ERROR running script Crit Counter (Alias59) ERROR:[string "if not CritCounter then..."]:179:
attempt to concatenate field '?' (a nil value)
regex ^Your attacks strike a? (.*) with\!(?:!!)?$
script CritCounter:AddCrit(matches[3])
script:
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) .. "[ ")
cecho("<yellow>DAMAGE REPORT:")
cecho("<grey> ]" .. string.rep("-", 31) .. "\n")
echo("\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
local line = "<light_goldenrod_yellow>" .. crit .. ":"
line = line .. string.rep(" ", 20 - string.len(crit))
line = line .. "<white>" .. self._critTable[crit]
line = line .. " <LimeGreen>[ " .. string.format("%.3f", rate)
if rate < 100 then line = line .. " " end
if rate < 10 then line = line .. " " end
line = line .. " ] - "
line = line .. self._critLast[crit] .. " hits ago!"
cecho(line .. "\n")
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()
Damage Counter script errors
Re: Damage Counter script errors
You can encase all this with lua tags. Makes it much easier to view.
What is your question?
What is your question?
Re: Damage Counter script errors
Tagged for easy reading.
noblestone wrote:Your attacks strike A zombie 2 times, with *DISMEMBERING* viciousness!
Your attacks strike A zombie 5 times, with demolishing ferocity!
Your attacks strike A half-decomposed zombie 3 times, with **MASSACRING** passion!
LUA: ERROR running script Crit Counter (Alias59) ERROR:[string "if not CritCounter then..."]:179:
attempt to concatenate field '?' (a nil value)
regex ^Your attacks strike a? (.*) with\!(?:!!)?$
script CritCounter:AddCrit(matches[3])
script:
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Damage Counter script errors
LUA: ERROR running script Crit Counter (Alias59) ERROR:[string "if not CritCounter then..."]:179:
attempt to concatenate field '?' (a nil value)
That is what fired when i ran debug, also crit show table doesnt even show all damage as result too.
^crit (on|off|show|reset)$ <--- alias below is code bascially those all above is connected.
if matches[2] == "show" then
CritCounter:display()
elseif matches[2] == "reset" then
CritCounter:Reset()
else
local en = matches[2] == "on" and true or false
CritCounter:Enable(true)
end
attempt to concatenate field '?' (a nil value)
That is what fired when i ran debug, also crit show table doesnt even show all damage as result too.
^crit (on|off|show|reset)$ <--- alias below is code bascially those all above is connected.
if matches[2] == "show" then
CritCounter:display()
elseif matches[2] == "reset" then
CritCounter:Reset()
else
local en = matches[2] == "on" and true or false
CritCounter:Enable(true)
end
Re: Damage Counter script errors
In the simplest possible way, the error you are getting means you are trying to do a string concatenation using a nil value, rather than a string, on whatever line is line 179 in that script. Find the line where it is happening, and it should be fairly easy to pin down what is going on to cause the problem.
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Damage Counter script errors
The script looks fine, dont know why it wont fire. Care to pinpoint this down for me please.
Re: Damage Counter script errors
First, here is the function where the error is occurring (Assuming you posted the whole script, and my resulting line numbers are correct):
So, I modified this function to show when a nil value was encountered that might cause a problem. I also consolidated all the stuff where you were constructing the line variable, so it would be easier for me to look at, the results should be identical visually.
If you put in the replacement function, you should get a print out of any nil variable values right before the error occurs (since it will happen in the line assigning a value to the line variable), which should help narrow down the problem.
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Damage Counter script errors
The result fired back:
-------------------------------[ DAMAGE REPORT: ]-------------------------------
Total hits: 5
Total crits: 0
Total crit-rate: 0.000
Statistics:
NIL VARIABLE: self._critTable[crit]
NIL VARIABLE: self._critLast[crit]
-------------------------------[ DAMAGE REPORT: ]-------------------------------
Total hits: 5
Total crits: 0
Total crit-rate: 0.000
Statistics:
NIL VARIABLE: self._critTable[crit]
NIL VARIABLE: self._critLast[crit]
Re: Damage Counter script errors
So, if you print out the value of crit in those if statements, you will likely be able to see what is missing and/or messed up with your tables.
-
- Posts: 154
- Joined: Sun Jul 29, 2012 6:50 am
Re: Damage Counter script errors
give me an example on how to do that and print ? That would be helpful. Thanks