View Single Post
11-17-20, 10:00 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,917
The problem with making a value public means that any addon that uses the same name for one of their values can cause the addon to break.


For example:


Addon 1 :
function PrintMe()
print("me")
end


Addon 2 :
PrintMe = "Me"


Now .. anytime addon 1 tries to call the function PrintMe() it will issue an error as addon 2 has replaced the name PrintMe with a string value.


This is one of the reasons why addons will make values they do not want touched private, and those they do they make public but manage to make sure they haven't been changed before using it.


Now, for identifying how addons are utilising their slash commands, if they have any is to look for the phrase SlashCmdList.

For another example:

SlashCmdList["XMP"] = SlashCommands

This is from my Mage Portals addon. SlashCommands is a private function that handles my addons few slash commands. However, SlashCmdList is a public table.

If you do the following you may be able to access information about the Slash Commands via the table.

for i,v in pairs(SlashCmdList) do
print(i,type(v))
end

The above should print the main slash command key ( in my addons case 'XMP' and then what type the value assigned to it is. I suspect it will almost always be a function but I haven't needed to look at it to know for sure.



The Stop Watch addon you are looking at has the following

SLASH_MORESTOPWATCHESCONFIG1 = "/morestopwatches";
SLASH_MORESTOPWATCHESCONFIG2 = "/msw";
SlashCmdList["MORESTOPWATCHESCONFIG"] = MoreStopwatches.ConfigSlash;

As you can see in this example .. the key string is the name of the Slash Command prefixed by SLASH_ and suffixed by a number starting from 1. This addon has made these public along with the function assigned to the SlashCmdList table entry for the addon. This should give you access to the function but you would still have to read the code to identify the commands that you type after /msw etc. There is no magic trick to access the command strings.

The addon I mentioned before, nUI, stores its command strings into a public table and it is that table I access via my menu system addon to access the slash commands via menu. If it hadn't had that ability I would have had to read through every piece of the slash command code to see if it was publicly accessible and what key and command strings to use to execute a specific functionality. The stopwatch addon doesn't do that and so you do not have programmatic access to what follows the /msw slash command key to work.

Looking through the code for the stopwatch addon the following are the commands you can use.

/msw header or /msw headers - Toggle Permanent Headers
/msw closeall or /msw close or /msw hide - Hide the timers
/msw help - To display list of commands
/msw help header or /msw help close - Description of the specific command

/msw - on its own it will display a message on how to create new timers via /sw <Name>

Hopefully that answers your question .. if not perhaps you can explain exactly what you were hoping to do and maybe someone can help.
__________________
  Reply With Quote