Reply
Thread Tools Display Modes
Unread 06-16-11, 07:58 AM   #1
TLH
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 8
Slash-command aliases

Is it possible to make a custom slash-command that mimics any other general slash-command? This is purely for convenience; an example of what I'm looking to do is have it so that typing /hg will be an alias for typing /use Have Group, Will Travel.

While this would be possible* via Lua script if CastSpellByName were not a protected function, it remains the case that typing /use is deemed acceptable. Since I'm not looking to automate anything, I can't think of a logical reason why it wouldn't be equally acceptable to type something else for the same effect.

Mainly asking because it seems like there would be no harm in it, and feels like something that should be possible.


*I've already made myself several short-hand commands for common pieces of script I use
TLH is offline   Reply With Quote
Unread 06-16-11, 09:55 AM   #2
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 764
Yes you can, slash commands work like this:

The function itself is in SlashCmdList["UniqueString"]

The "/..." is in SLASH_UniqueString1 = "/..." so all you got to do is find what "UniqueString" is and add one number higher and your own "/..." for example:
SLASH_UniqueString2 = "/mycmd"

In GlobalStrings.lua you got:
SLASH_USE2 = "/use";
SLASH_CAST4 = "/spell"; -- aka /cast
SLASH_CASTRANDOM2 = "/castrandom";
SLASH_CASTSEQUENCE2 = "/castsequence";
SLASH_CANCELAURA2 = "/cancelaura";
SLASH_CANCELFORM2 = "/cancelform";
(and many more)

For to have an alias for /use you could:
SLASH_USE3 = "/u"

I believe it would work

Last edited by Vlad : 06-16-11 at 09:58 AM.
Vlad is offline   Reply With Quote
Unread 06-16-11, 10:30 AM   #3
TLH
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 8
Close! Is there a way to also include an argument as part of the alias?
What I'm getting at is this:

If I wanted to make it so /fs does the same thing as /yell Frostshooock! , I could do this:

SLASH_FS1 = "/fs";
SlashCmdList["FS"] = function()
SendChatMessage("Frostshooock!", "YELL");
end

That works, but is avoiding the issue by doing it via script, which has no (unprotected) function to mimic /use with an argument.

I'm trying to get /hg to mimic /use Have Group, Will Travel; /gb to mimic /use Mobile Banking; etc.
TLH is offline   Reply With Quote
Unread 06-16-11, 10:39 AM   #4
Foxlit
A Warpwood Thunder Caller
 
Foxlit's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
This cannot actually be done; secure slash commands like /use or /cast are protected and cannot be extended by modifying the global SLASH_FOOn variables.
__________________
... and you do get used to it, after a while.

Last edited by Foxlit : 06-16-11 at 11:41 AM.
Foxlit is offline   Reply With Quote
Unread 06-16-11, 01:03 PM   #5
TLH
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Aug 2010
Posts: 8
Mm, I thought I'd check at least, in the hope that Blizzard might have allowed it since it would not enable automation.

Thanks!
TLH is offline   Reply With Quote
Unread 06-16-11, 03:15 PM   #6
humfras
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 97
Originally Posted by TLH View Post
Mm, I thought I'd check at least, in the hope that Blizzard might have allowed it since it would not enable automation.
Since these commands would be processed in unrestricted, unprotected LUA, automation would be possible.

If you want a macro with more than 256 characters, use something like Macaroon or create a SecureActionButton with a macro-action.
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker
humfras is offline   Reply With Quote
Unread 06-16-11, 03:43 PM   #7
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 764
Just one thing, if the function itself is secure why would the / mater really? Can't seem to figure this one out. If you add, remove or change the SLASH_XY global variable imo it shouldn't matter because the function is what is being triggered... maybe I am not getting something.
Vlad is offline   Reply With Quote
Unread 06-17-11, 12:48 AM   #8
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,054
Anything an AddOn (or a user typing /script) does that modifies _anything_ in the default UI causes taint, which is Blizzard's way of saying "Hey - this was touched by a user and could have possible un-intended results". Anything which has been tainted cannot perform secure actions.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of Revelation, Spamalyzer, TravelAgent, Volumizer, and many other AddOns.
Torhal is online now   Reply With Quote
Reply

Go BackWoWInterface » AddOns, Compilations, Macros » Macro Help » Slash-command aliases

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