Thread Tools Display Modes
04/22/14, 07:38 AM   #1
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by thelegendaryof View Post
*cought* (backs off and checks his globals for possible retarded names and duplicates)
You're not alone...

Trust me, I rushed through developing InventoryInsight and I have been trying to balance my time between adding features and CLEANING the code lately. I know I shouldn't have any global that will interfere with other addons but they are also not necessarily standardized... So yes, even I am going back and trying to heed my own words.
  Reply With Quote
04/22/14, 09:25 AM   #2
ins
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 76
Originally Posted by Vicster0 View Post
You're not alone...

Trust me, I rushed through developing InventoryInsight and I have been trying to balance my time between adding features and CLEANING the code lately. I know I shouldn't have any global that will interfere with other addons but they are also not necessarily standardized... So yes, even I am going back and trying to heed my own words.
I admitted defeat and redid the whole addon (the messiest one), as it was easier to write it from the ground up than fix a mess.

Only 4 more to go.

Edit:
Hot off the trail of the global/local talk.

Just had my first bug report as a bank addon and mine both had the same "function commandHandler "
Which apparently led to some issues when the user typed /mb to see commands in the other addon, and got for one of my first ****ty ones.

Did a quick fix to local everything, and moving functions around so they are reffering to each other in the right sequence (of code) and now I think that problem is out of the way.

Really really need to do a rewrite though.

Last edited by ins : 04/22/14 at 11:14 AM.
  Reply With Quote
04/22/14, 11:59 AM   #3
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Stormknight View Post
Agreed, this saves me loads of time and should be enough incentive for any author to want to work in this manner.

Another one to add in here is slash commands.

I ran into this recently when I (as others have mentioned) was mashing code together quickly to get my first addon working. Awesome Info. As part of this, I created a slash command of /ai

Seemed reasonable at the time, then later other authors created addons with the same two letter slash command and suddenly there was an issue. AutoInvite is one.

I changed my slash command to something longer as I was only using it during debugging anyway.


So .... worth adding a reference page on the Wiki for slash commands and another for global namespace?

I don't know whether enough authors would check it to make it worthwhile is the problem.
This is exactly how it happens! I am currently using two slash commands for both of my addons but you are entirely right, the shorter ones probably just need to go away... Two letters is far too common and can/will cause future problems with other addons, INCLUDING your own!! LOL

I'm glad you brought this up though, I will make a note for that to be one thing to fix in this major version of InventoryInsight I'm working on right now.

Originally Posted by ins View Post
I admitted defeat and redid the whole addon (the messiest one), as it was easier to write it from the ground up than fix a mess.

Only 4 more to go.

Edit:
Hot off the trail of the global/local talk.

Just had my first bug report as a bank addon and mine both had the same "function commandHandler "
Which apparently led to some issues when the user typed /mb to see commands in the other addon, and got for one of my first ****ty ones.

Did a quick fix to local everything, and moving functions around so they are reffering to each other in the right sequence (of code) and now I think that problem is out of the way.

Really really need to do a rewrite though.
Dude, that's funny. I want everyone to consider what was said here for a second... ESO has been live for a very short time and technically there are only a handful of addons for this game's UI at this time (compared to say WoW). With that being said, there are ALREADY overlap issues occurring. Even with addons from the same author!!

Better the mistakes be caught now and learned than to avalanche into the future. Thanks for sharing that with us Ins!
  Reply With Quote
04/22/14, 12:46 PM   #4
Halja
 
Halja's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 111
The interaction can be total strange too. Garkin and I had a brief add-on conflict. It had to do with the lua convention of dumping unused return values to an underscore character. Inside on of Skyshards locally decared functions was.

Code:
_,_,_,zone,subzone = string.find(textureName, "(maps/)(%w+)/(%w+_%w+)")
In ESOTheater, I had for whatever unknown reason had '_' in the relative parent position when setting an anchor.
Code:
tcontrol:SetAnchor(TOP, _, _, x, y)
If Skyshards loaded before mine, boom. The game tired to use the value from Skyshards on the set anchor. Easy to fix but very unexpected.

Cheers,
halja
  Reply With Quote
04/22/14, 12:55 PM   #5
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Halja View Post
The interaction can be total strange too. Garkin and I had a brief add-on conflict. It had to do with the lua convention of dumping unused return values to an underscore character. Inside on of Skyshards locally decared functions was.

Code:
_,_,_,zone,subzone = string.find(textureName, "(maps/)(%w+)/(%w+_%w+)")
In ESOTheater, I had for whatever unknown reason had '_' in the relative parent position when setting an anchor.
Code:
tcontrol:SetAnchor(TOP, _, _, x, y)
If Skyshards loaded before mine, boom. The game tired to use the value from Skyshards on the set anchor. Easy to fix but very unexpected.

Cheers,
halja

Pro-tip:

Only use '_,' during variable assignments. If your intention is to pass nothing, then pass nothing aka nil.

For example:

Lua Code:
  1. local someValue = 10
  2. local _, val1, val2 = GiveMeThreeValues( nil, someValue )
  3.  
  4. function GiveMeThreeValues( arg1, arg2 )
  5.     if( agr1 and arg2 ) then
  6.         --arg1 ~= nil
  7.         --arg2 ~= nil
  8.         return arg1, arg2, (arg1 + arg2)
  9.     end
  10.     if( agr1 ) then
  11.         --arg1 ~= nil
  12.         return arg1, arg1, (arg1 + arg1)
  13.     end
  14.     if( agr2 ) then
  15.         --arg2 ~= nil
  16.         return arg2, arg2, (arg2 + arg2)
  17.     end
  18.     --just some nonesense for example...
  19. end

I believe '_' is still a variable as far as LUA is concerned...
At least, this is how I see it...

Last edited by Vicster0 : 04/22/14 at 12:59 PM.
  Reply With Quote
04/22/14, 04:14 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Originally Posted by Vicster0 View Post
I believe '_' is still a variable as far as LUA is concerned...
At least, this is how I see it...
Yes. _ is just as valid a variable name as any other. It should be treated with just as much care (declaring it local) as any other variable you create/use. It's just convention that people use it as a "throw-away" variable when doing assignments from function returns. You can declare _ local at the top of your file, in the main chunk, and then use it 20 times if you want. No need to declare it local every time.

Originally Posted by Vicster0 View Post
If your intention is to pass nothing, then pass nothing aka nil.
Also, yes. It just worked in your testing because _ wasn't assigned to any value and equaled nil. It would work the same way if you used VariableIWantToStayNil instead of _. Well, until someone else leaked the same variable as a global...


/edit: oh yeah - and you can have more than one slash command for your addon. Just have them point to the same function. Leave the short one in as a shortcut if a user doesn't have another addon installed with the same command.
  Reply With Quote
04/22/14, 07:30 PM   #7
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by Seerah View Post
/edit: oh yeah - and you can have more than one slash command for your addon. Just have them point to the same function. Leave the short one in as a shortcut if a user doesn't have another addon installed with the same command.
Oh yeah, you definitely can. However, I think I will be removing mine... I guess the thing here is, the entropy when you are dealing with 2-3 characters isn't much and EVENTUALLY someone is going to use the same shorthand slash command. (As in Stormknight's case for instance.) If your addon's default slash command is pretty long then maybe having a alternate with 6 or so characters would be nice and reasonable less dangerous due to the increased entropy. However, I think in some cases, likely frequent, shortening to 6 characters is really not that much better than the default. :P

Plus, I'm just saying, slash commands are kind old school... Maybe for backend dev/qa but for prod? I dunno.. lol LibAddonMenu is pretty freakin' simple...

And that's coming from someone who spends the better portion of his day in a CLI...
  Reply With Quote
04/22/14, 01:12 PM   #8
ins
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 76
Originally Posted by Vicster0 View Post
Y

Dude, that's funny. I want everyone to consider what was said here for a second... ESO has been live for a very short time and technically there are only a handful of addons for this game's UI at this time (compared to say WoW). With that being said, there are ALREADY overlap issues occurring. Even with addons from the same author!!

Better the mistakes be caught now and learned than to avalanche into the future. Thanks for sharing that with us Ins!
Nono, it was my addon and BadVolts. The reason being I think was that we both used the same code example when we made our commandHandler - Edit: The wiki has a few examples using global functions instead of local as well.

Edit: Oh yea, Shardwatch apparently had the same global. Funny I've had both installed for ages and never ran into a problem with either, despite both functions named commandHandler.. So it is too now Local.

Last edited by ins : 04/22/14 at 01:16 PM.
  Reply With Quote
04/22/14, 01:46 PM   #9
Vicster0
 
Vicster0's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 82
Originally Posted by ins View Post
Nono, it was my addon and BadVolts. The reason being I think was that we both used the same code example when we made our commandHandler - Edit: The wiki has a few examples using global functions instead of local as well.

Edit: Oh yea, Shardwatch apparently had the same global. Funny I've had both installed for ages and never ran into a problem with either, despite both functions named commandHandler.. So it is too now Local.
Oh, I knew what you meant!

I'm only saying that, if that can happen because you both use the same template to create the function, what's to say you don't create the same function again, globally, and somewhat different in a separate addon. It has happened before. lol
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Addon Etiquette

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off