Thread Tools Display Modes
11-17-20, 01:49 AM   #1
usiname
A Defias Bandit
Join Date: Nov 2020
Posts: 3
How to execute addon command in .lua

I'm trying to make very basic addon to command other addon. I found how to do this via the command SlashCmdList and example for this with recount SlashCmdList["ACECONSOLE_RECOUNT"]("show"), but how to find the specific library used by other addon? Recoutn using ACECONSOLE_RECOUNT, but in other addons i can't find anything like this.
I am trying to find this out for MoreStopwatches https://www.curseforge.com/wow/addons/more-stopwatches

Last edited by usiname : 11-17-20 at 01:52 AM.
  Reply With Quote
11-17-20, 07:42 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
You would only have access to public values in other addons. If they have made them public then you can. You would have to look at the code for each addon to identify the values you will need access to and see if there is a public access to it. If not, you will be out of luck unless the developer is willing to add the additional features you are wanting to add.

For example:
In most of my own addons the variables are private as I only want the addon itself to access the information ..

But in nUI the values are public, so plugin addons can be created that hook into those values to do something that nUI doesn't do itself. Such as convert the slash command system into a UI or menu system to get the same functionality via a different interface.
__________________
  Reply With Quote
11-17-20, 08:45 AM   #3
usiname
A Defias Bandit
Join Date: Nov 2020
Posts: 3
But how to identify the key library that can allow me to to run commands, is here any special think for what I must to looking? I think in this addon most of the variables private, but I make this only for personal needs and will never share it with someone so is here problem to make the variables public?
  Reply With Quote
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,892
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
11-17-20, 11:38 AM   #5
usiname
A Defias Bandit
Join Date: Nov 2020
Posts: 3
Thank you, I am trying to use this addon to make timers for my rotation for specific bosses and make it to work automatic instead to trace everything.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » How to execute addon command in .lua

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