I am bugfixing MrBigglesworthDeath () and adding features like slash commands. The lua code is http://pastey.net/111002 and the localization is http://pastey.net/111003 but I am getting errors that don't make sense to me.
The current error is MrBigglesworthDeath.lua:55: Attempt to index global 'DeathFrame' (a nil value)
I am sure there are other errors, and the possibility that the whole addon won't work if PARTY_KILL doesn't pick up party/raid pets or someone feeding Critter Bites to the cat.
I am also concerned about making functions and variables local to the addon. Did I go far enough, too far?
Is my localization correct, or even my slash commands and their handler?
This is the first addon I've tried making wholesale by myself, rather than fixing someone else's work like I did with SmartRes, so if I sound like a noob, then I admit I'm a noob.
Gotcha. *shakes head* such a simple error. Anyway, I found others, fixed them, then found out the variable biggsName was reporting nil http://pastey.net/111017 yet line 49 defines biggsName as the mobid. I think this has something to do with line 94, but try as I might, I can't seem to nail the bug down.
Also, when I checked the savedvariables file, it reads: MrBigglesworthDeathDB = nil
so I must not be declaring the DB correctly. I tried the wiki, but that's how I got what I have.
is what it turned into when i redid you code. I reFormatted it to the way i write addon stubs. Mind you this is an All Lua Implementation, no XML like your origional had.
Thank you very much, OrionShock. I take it by the XML you meant the OnLoad bit? Yeah, I needed to change that, as I didn't have any .xml file.
While I understand what you did, other than coding style preference, I am not sure why you wrote the code this way. Also, I removed my locales folder, as hinted by your code, and put the translations directly into MrBigglesworthDeath.lua at the top. Furthermore, line 59 throws an error: attempt to index local 'self', (a string value). It looks like a string to me.
Here is the .zip of my addon, with all the files, less my locale folder, which seems obsolete now.
I really appreciate the help, and thank you greatly. I am trying to learn from my mistakes, bouncing back and forth between Cladhaire's book, the wiki, and looking at existing addons' code.
In the event handler, i wasn't passing the addon object first. minor oversight in the handler.
Pointers of interest:
When doing true/fase evaluations don't test for true/fase directly. IE
if var == true then ... end
do this instead, it's a bit easier on readablity.
if var then ... end
If the value your working with is true or false by simple definition of use then the if/then block will do that for you. Now if the value your testing is indeed changing or needs that evaluation that is not true false, then a direct compare is warrented, like in a simple event handler you had before.
local function eventHandler(frame, event, ...)
if event == "SOME_EVENT" then
DoSomething()
elseif event == "SOME_OTHER_EVENT" then
SomeOtherEvent()
end
end
This is valid b/c the value being worked with is not inherently true/false. Might be obvious but you where doing it all over the place. :)
Also in your "isMrBigglesWorth" function, the idea of keeping it simple comes to mind. Fact is that Mr. Bigglesworth will Always be an NPC and Mob, even if someone charms it, the MobID remains the same regardless. So checking if it's an NPC is redundant. Simply decode the GUID and test it agenst the known mob id.
Where did the "self:InitializeDB("MrBigglesworthDeathDB", self.defaults) " come from too? did you emebed AceDB2 in somewhere you didn't post?
--Those are just the ideas i see right off the bat.. if you have any specific questions on how or why i did certain things i'd be happy to explain.
Alright, the irony of your true/false suggestion is that I find it more readable the other way, but I have seen many an addon do it your way, and while it makes me think for a moment, I too can decipher the if/then.
As for the simplicity about "isMrBigglesWorth" yes, much cleaner. I take it that if a pet were to kill the cat, the COMBAT_LOG_EVENT_UNFILTERED PARTY_KILL would still fire? Same goes for Critter Bites? I will have to test.
No Ace, and I can't remember where I got that code from, as it is very Ace-centric.
Questions: I see addons doing localization either in the main .lua file as you have it, or in a seperate file. I would think that if someone where to provide localized info for this addon, having a seperate \locales\Localization.enUS.lua would be preferable.
If I were to go and create a seperate locale folder & file, would I change MrBigglesworthDeath.lua as follows:
local L = MrBigglesworthDeathLocalization
and the \locales\localization.enUS.lua
MrBigglesworthDeathLocalization = {
MBD_INSTRUCTIONS = "Slash commands are /mrbigglesworthdeath or /mbd followed by \"sound on\" or \"sound off\" or \"defaults\" without the quotes.",
SOUNDON = "sound on",
SOUNDOFF = "sound off",
MBD_SOUNDON_MSSG = "Thunder sound on.",
MBD_SOUNDOFF_MSSG = "Thunder sound off.",
DEATH_MESSAGE = " %s killed %s, May he Rest In peace",
}
Or do I still need the GetLocale() in the second file?
And just out of curiousity, what creature is mobid "1316" that you tested on?
** EDIT** http://pastey.net/111148 I found the slash instructions weren't working correctly; I fixed those. Also added the localization text, removed the ")" at the end that threw an error, then tested.
No errors! Slash commands work! But still not playing the sound file. I checked the path and spelling (had to fix the extension) then I realized the problem is not near line 114. The variable is being saved correctly I checked. I think it is in the slash handler function, with the local "opt" and there seems to be missing code to switch the settings. Am I correct?
If so, then would the otherwise blank line 95 read:
There are plenty of different methods for doing locales. If you only have about 15 or less strings, then putting the localizations in the main file is ok. As for implementation of how to do the localization code.. again many ways. The Mehod your using is what i'd call "Global Var Style in a Table". Where the table keys and localizations have little relation and are stuck in a table to avoid cluttering up the global table.
While this is fine, and works.. just a bit odd for me. I always have 30+ strings usualy. One method is to wrap each localization block in a "if GetLocale() == "--??" then ... end", and simply declare the english one first w/o a GetLocale() block. I've seen ckknight use a very long logic chain "L = GetLocale() == "enUS" and {} or GetLocale() =="--??" and {} .... " chain, rather odd method i'd say.
As for the mob ID, i got it from your code i think. As for the CLEU event and a pet killing the cat, no clue.
On a note about uploading this via TortoiseSVN, I tried to post the soundless, yet mostly working, addon. Errors...
1. right-clicked my Addons folder and did svn checkout using svn://myrroddin@svn.curseforge.net/wow/biggs-death/mainline/trunk
2. changed the "mainline" suggested folder to "MrBigglesworthDeath
3. clicked OK
4. new addon folder created, contents: a hidden folder called .svn
5. copied updated files from working folder into MrBigglesworthDeath folder
6. right clicked new items and selected "Add" via TortoiseSVN
7. up a level, and selected "SVN commit" and typed "build 1.2" in recent messages
8. Commit failed error
Commit failed (details follow):
'pre-commit' hook failed with error output:
Please set the svn:eol-style property on the following files:
trunk/MrBigglesworthDeath.lua
trunk/MrBigglesworthDeath.toc
If you don't know what the property does, set it to 'native'.
Do I need to do SVN update for step 7 instead? I tried that, and did not get errors.
as for your commit error, right click on each file and go to (svn)Properties. Add one , key: "svn:eol-style" and value = "native"
I always went in and set the defaults to do this, but that requires a bit of config file editing.
As for the slash handler, it should be setting the option correctly. A table is a table is a table. Even if you "rename" a table when you attach it somewhere else, it is still the same table everywhere. Make a change in one place and that change is still the same everywhere else that the same table is link at.
try, http://pastey.net/111150-2u93, see if that works better.. i think the added check to make sure it dosn't turn off an option that's already off might be throwing something. Also i put the table back on the addon object at the end of the slash handler, tho it shouldn't be needed.
You aren't going to believe how silly this sounds, (pun included) but I solved the riddle of the thunder. wav ... Look at line 115; I took out the "\\" before the word "Interface" and it works like a charm. *shakes head* ???
Alright, for all the help, would you like a credit? I think you deserve one, but I am giving you the option.
it works fine for me, but one thing that i noticed the other day, if the person who kills him is more then (im guessing) like 50yd away, it wont know who did it. So im wondering if somewhere their is a code that can see everything all across the say 100yd radius. It may be me, but i find this the COOLEST addon i ever got ^_^
So I replied with:
I can check to see if there is anything that can be done, but I think the limitation is based on the Combat Log's range, which is about 50 yards, as you noticed.
If there is something I can do about the range, I will adjust the change log accordingly.
And thank you. I'm glad you like it!
Would I be correct in thinking the limitation is the CLEU range? And if so, is there a way within the addon to increase detection?
I will change the default chat output to RAID from the current SAY; at that point, the user will only miss out on the thunder sound effect.
Also, I tested this addon the other night by feeding the cat a Critter Bite, and the addon did not go off, probably because it was not a PARTY_KILL event. UNIT_DIED or UNIT_DESTROYED don't seem right, but that is because of a lack of parameters. Or at least, a lack on wowwiki.
The range of picking up combat log events is everything you can see. Text from /say is viewable over considerably less distance. To the best of my knowledge the radius of "/say pickup" cannot be adjusted, but I admit to having done no investigation on that specifically. (I imagine that if it were adjustable, there would already be addons adjusting it.)
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
The current error is MrBigglesworthDeath.lua:55: Attempt to index global 'DeathFrame' (a nil value)
I am sure there are other errors, and the possibility that the whole addon won't work if PARTY_KILL doesn't pick up party/raid pets or someone feeding Critter Bites to the cat.
I am also concerned about making functions and variables local to the addon. Did I go far enough, too far?
Is my localization correct, or even my slash commands and their handler?
This is the first addon I've tried making wholesale by myself, rather than fixing someone else's work like I did with SmartRes, so if I sound like a noob, then I admit I'm a noob.
Basically that line currently says (in layman's-english).
"If we got something then, make our frame again"
what you want is
"If we don't got something then make our frame"
http://pastey.net/111017 yet line 49 defines biggsName as the mobid. I think this has something to do with line 94, but try as I might, I can't seem to nail the bug down.
Also, when I checked the savedvariables file, it reads: MrBigglesworthDeathDB = nil
so I must not be declaring the DB correctly. I tried the wiki, but that's how I got what I have.
http://pastey.net/111097
is what it turned into when i redid you code. I reFormatted it to the way i write addon stubs. Mind you this is an All Lua Implementation, no XML like your origional had.
While I understand what you did, other than coding style preference, I am not sure why you wrote the code this way. Also, I removed my locales folder, as hinted by your code, and put the translations directly into MrBigglesworthDeath.lua at the top. Furthermore, line 59 throws an error: attempt to index local 'self', (a string value). It looks like a string to me.
Here is the .zip of my addon, with all the files, less my locale folder, which seems obsolete now.
I really appreciate the help, and thank you greatly. I am trying to learn from my mistakes, bouncing back and forth between Cladhaire's book, the wiki, and looking at existing addons' code.
http://pastey.net/111132
In the event handler, i wasn't passing the addon object first. minor oversight in the handler.
Pointers of interest:
When doing true/fase evaluations don't test for true/fase directly. IE
do this instead, it's a bit easier on readablity.
If the value your working with is true or false by simple definition of use then the if/then block will do that for you. Now if the value your testing is indeed changing or needs that evaluation that is not true false, then a direct compare is warrented, like in a simple event handler you had before.
This is valid b/c the value being worked with is not inherently true/false. Might be obvious but you where doing it all over the place. :)
Also in your "isMrBigglesWorth" function, the idea of keeping it simple comes to mind. Fact is that Mr. Bigglesworth will Always be an NPC and Mob, even if someone charms it, the MobID remains the same regardless. So checking if it's an NPC is redundant. Simply decode the GUID and test it agenst the known mob id.
Where did the "self:InitializeDB("MrBigglesworthDeathDB", self.defaults) " come from too? did you emebed AceDB2 in somewhere you didn't post?
--Those are just the ideas i see right off the bat.. if you have any specific questions on how or why i did certain things i'd be happy to explain.
As for the simplicity about "isMrBigglesWorth" yes, much cleaner. I take it that if a pet were to kill the cat, the COMBAT_LOG_EVENT_UNFILTERED PARTY_KILL would still fire? Same goes for Critter Bites? I will have to test.
No Ace, and I can't remember where I got that code from, as it is very Ace-centric.
Questions: I see addons doing localization either in the main .lua file as you have it, or in a seperate file. I would think that if someone where to provide localized info for this addon, having a seperate \locales\Localization.enUS.lua would be preferable.
If I were to go and create a seperate locale folder & file, would I change MrBigglesworthDeath.lua as follows:
and the \locales\localization.enUS.lua
Or do I still need the GetLocale() in the second file?
And just out of curiousity, what creature is mobid "1316" that you tested on?
** EDIT**
http://pastey.net/111148 I found the slash instructions weren't working correctly; I fixed those. Also added the localization text, removed the ")" at the end that threw an error, then tested.
No errors! Slash commands work! But still not playing the sound file. I checked the path and spelling (had to fix the extension) then I realized the problem is not near line 114. The variable is being saved correctly I checked. I think it is in the slash handler function, with the local "opt" and there seems to be missing code to switch the settings. Am I correct?
If so, then would the otherwise blank line 95 read: or is it a bit more intensive than that?
While this is fine, and works.. just a bit odd for me. I always have 30+ strings usualy. One method is to wrap each localization block in a "if GetLocale() == "--??" then ... end", and simply declare the english one first w/o a GetLocale() block. I've seen ckknight use a very long logic chain "L = GetLocale() == "enUS" and {} or GetLocale() =="--??" and {} .... " chain, rather odd method i'd say.
As for the mob ID, i got it from your code i think. As for the CLEU event and a pet killing the cat, no clue.
On a note about uploading this via TortoiseSVN, I tried to post the soundless, yet mostly working, addon. Errors...
1. right-clicked my Addons folder and did svn checkout using svn://myrroddin@svn.curseforge.net/wow/biggs-death/mainline/trunk
2. changed the "mainline" suggested folder to "MrBigglesworthDeath
3. clicked OK
4. new addon folder created, contents: a hidden folder called .svn
5. copied updated files from working folder into MrBigglesworthDeath folder
6. right clicked new items and selected "Add" via TortoiseSVN
7. up a level, and selected "SVN commit" and typed "build 1.2" in recent messages
8. Commit failed error
Do I need to do SVN update for step 7 instead? I tried that, and did not get errors.
I always went in and set the defaults to do this, but that requires a bit of config file editing.
As for the slash handler, it should be setting the option correctly. A table is a table is a table. Even if you "rename" a table when you attach it somewhere else, it is still the same table everywhere. Make a change in one place and that change is still the same everywhere else that the same table is link at.
try, http://pastey.net/111150-2u93, see if that works better.. i think the added check to make sure it dosn't turn off an option that's already off might be throwing something. Also i put the table back on the addon object at the end of the slash handler, tho it shouldn't be needed.
Alright, for all the help, would you like a credit? I think you deserve one, but I am giving you the option.
So I replied with:
Would I be correct in thinking the limitation is the CLEU range? And if so, is there a way within the addon to increase detection?
I will change the default chat output to RAID from the current SAY; at that point, the user will only miss out on the thunder sound effect.
Also, I tested this addon the other night by feeding the cat a Critter Bite, and the addon did not go off, probably because it was not a PARTY_KILL event. UNIT_DIED or UNIT_DESTROYED don't seem right, but that is because of a lack of parameters. Or at least, a lack on wowwiki.
Suggestions, if any?