Quantcast
Open Map From Slash Command - WoWInterface
Thread Tools Display Modes
04-15-21, 12:24 AM   #1
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Open Map From Slash Command

I am trying to open the world map to the zone with the player's current waypoint pinned to it.

If the map is already open, my slash command can set the zone just fine using WorldMapFrame:SetMapID(uiMapID).

If the map is closed and I'm out of combat, I can do OpenWorldMap(uiMapID), and it works fine.

If I'm in combat, however, OpenWorldMap doesn't work - it's protected. Right now, what I'm doing is waiting for PLAYER_REGEN_ENABLED to open the map, but my understanding is that it should be possible to call protected functions like this so long as the call originates from a hardware event, and entering and sending a slash command seems like a hardware event. So unless I misunderstand, it should be possible to have a slash command open the map window.

But I'm really having trouble understanding how precisely these secure handlers/templates work from the documentation I can find.

If it is possible, it would be really helpful if someone could give me a simple example of how to make a slash command open the map - that would both solve my problem and help me to understand how to deal with protected functions in general. Or, if I'm misunderstanding and it's not possible, I'm wondering if there's any other way to open the map from a non-secure environment during combat.

Last edited by samueldcorbin : 04-15-21 at 12:30 AM.
  Reply With Quote
04-15-21, 05:20 AM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 550
Concerning the very first sentence, what is your end goal? A pin you can immediately shiftclick to share? I have some custom code I can share later when I get the chance that generates a pin at your location that can then share it to a channel or even a whisper directly. This will skip the need for the map entirely.
  Reply With Quote
04-15-21, 10:39 AM   #3
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
My goal at the moment is literally a command that opens the map to the map with the user's current pin on it.

I already have what you are describing. I'm trying to figure out how to open the map - both to write this particular slash command, and to better understand how protected functions work.
  Reply With Quote
04-16-21, 08:51 PM   #4
DahkCeles
A Cyclonian
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 48
Slash commands don't allow secure actions, unfortunately. You actually have to click something, such as making a macro and then assigning it to an action button.
  Reply With Quote
04-16-21, 08:54 PM   #5
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by DahkCeles View Post
Slash commands don't allow secure actions, unfortunately. You actually have to click something, such as making a macro and then assigning it to an action button.
Hrm, I came across several posts from a couple of years ago suggesting that it could be initiated by a click or slash command - though none of them explained how. I'm guessing a click generated by a slash command can't trigger a secure button either.

Feels pretty silly that there's no way to open the map frame in combat and no way to make a slash command trigger a secure action when the text is entered and sent via hardware events.

Last edited by samueldcorbin : 04-16-21 at 08:56 PM.
  Reply With Quote
04-17-21, 11:45 AM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,018
Originally Posted by samueldcorbin View Post
I came across several posts from a couple of years ago suggesting that it could be initiated by a click or slash command - though none of them explained how.
The UI changes over the years, and Blizzard has been known to do some really stupid things.



Originally Posted by samueldcorbin View Post
I'm guessing a click generated by a slash command can't trigger a secure button either.
You can do something like this, but it toggles the world map. There's no way to put a condition on it to check if it's already open.
Code:
/click MiniMapWorldMapButton


Originally Posted by samueldcorbin View Post
Feels pretty silly that there's no way to open the map frame in combat and no way to make a slash command trigger a secure action when the text is entered and sent via hardware events.
As a clarification, hardware-restricted and protected functions are two completely different categories of functions. Hardware-restricted (often called hardware-protected as if that doesn't make this topic more confusing) require a hardware event to run. Protected functions can only be run from a secure execution path. This means only Blizzard can run these functions directly. If an addon "taints" the execution path or attempts to call these functions directly, a taint error is thrown. Combat functions are protected functions that are only restricted during combat. This also extends to protected frames, which can't be manipulated during combat.

Apparently, the WorldMapFrame is a protected frame, whether directly or through one of its children. Remember, any frame that has a protected child is also considered a protected frame.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
04-17-21, 01:43 PM   #7
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by SDPhantom View Post
The UI changes over the years, and Blizzard has been known to do some really stupid things.
That's fair, though I couldn't find any change related to this. I think perhaps whoever said that originally was just mistaken.
Originally Posted by SDPhantom View Post
You can do something like this, but it toggles the world map. There's no way to put a condition on it to check if it's already open.
That actually doesn't seem to work in combat either - "Interaction failed because of an AddOn" (even run from /run with all addons disabled).

Poking around a bit more, it appears that WorldMapFrame isn't actually protected. You can call Show on it during combat, but certain things don't work correctly - like Escape won't clear the frame. The problem is that ShowUIPanel, which is what's normally used to call it, checks CheckProtectedFunctionsAllowed.
Originally Posted by SDPhantom View Post
This also extends to protected frames, which can't be manipulated during combat.
Protected frames can't be manipulated by addon code during combat, but isn't the whole point of things like SecureStateDriver to allow them to be manipulated during combat?

If I'm understanding correctly, it seems like the problem is ultimately just that there's no real way to have a slash command interact with something similar to a SecureHandlerClickTemplate - presumably because there's no option to write a slash command handler that executes in a restricted environment.
  Reply With Quote
04-19-21, 09:13 AM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,018
Originally Posted by samueldcorbin View Post
That actually doesn't seem to work in combat either - "Interaction failed because of an AddOn" (even run from /run with all addons disabled).
Running /click MiniMapWorldMapButton is still working fine for me (it's a chat command, not a Lua script). If you're trying to call MiniMapWorldMapButton:Click(), it won't work from a tainted execution path. While the function itself isn't protected, it doesn't magically cleanse the execution path.

Note: /run forces insecure mode and taints execution.



Originally Posted by samueldcorbin View Post
Poking around a bit more, it appears that WorldMapFrame isn't actually protected. You can call Show on it during combat
Strange. It was giving me a fit trying to call WorldMapFrame:Show() directly with addons disabled.



Originally Posted by samueldcorbin View Post
Protected frames can't be manipulated by addon code during combat, but isn't the whole point of things like SecureStateDriver to allow them to be manipulated during combat?
The SecureStateDriver basically assigns a value to a specified frame-oriented variable called an attribute by constantly evaluating macro conditionals. Setting a special attribute using it can show/hide a frame. It's a glorified unit watcher. Not what you're looking for.



Originally Posted by samueldcorbin View Post
If I'm understanding correctly, it seems like the problem is ultimately just that there's no real way to have a slash command interact with something similar to a SecureHandlerClickTemplate - presumably because there's no option to write a slash command handler that executes in a restricted environment.
Correct, though the Restricted Environment wouldn't have been much help either due to its limited access.
Note: No access to ShowUIPanel().

The SecureHandlerTemplates only works off mouse events, OnShow/OnHide, and attribute changes (see SecureStateDriver above).
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-19-21 at 09:17 AM.
  Reply With Quote
04-19-21, 02:28 PM   #9
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
with what you said here is a solution to always show the worldmap :
Code:
local handler = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")
local B = CreateFrame("button", "MAP", nil, "SecureActionButtonTemplate")
B:SetAttribute("type", "click")
B:SetAttribute("clickbutton",  MiniMapWorldMapButton)
function handler:MAP()
	WorldMapFrame:Hide()
end
handler:WrapScript(B, "PreClick", [[owner:CallMethod("MAP")]])
and the command is "/click MAP"
you can do a macro if you want

If you get :
Originally Posted by samueldcorbin View Post
That actually doesn't seem to work in combat either - "Interaction failed because of an AddOn"
that means one of your addon has tainted something

Last edited by Taudier : 04-19-21 at 02:45 PM.
  Reply With Quote
04-19-21, 08:03 PM   #10
DahkCeles
A Cyclonian
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 48
I believe any usage of the 8.0.1 map data provider API will taint the world map frame.
  Reply With Quote
04-19-21, 08:18 PM   #11
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Thank you for the answers.

I can WorldMapFrame:Show() so long as nothing else taints it, but the OnShow doesn't actually handle all the things you would normally get from showing the frame - several of them are handled by ShowUIPanel, which has a check for secure environment.

My intent was to alias the call to something else, not to do a native /click [something]. Using the built-in slash command does not work for what I'm trying to do. I assumed that since there were secure handlers that allowed hardware events to change frame attributes in predefined ways within a restricted environment, there might be a secure slash command template of some kind, but it looks like that's not the case.

I've just settled for having the addon open the map after combat ends (or set the map correctly if the player opens it manually in the interim).
  Reply With Quote
04-20-21, 01:02 AM   #12
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
don't you know how to read code ?

and if you can do "/click MAP" you can do whatever in secure env

SDPhantom pointed you a way to toggle the map
here is a solution to always show it
i'm sure you can figure out a way to hide it

Last edited by Taudier : 04-20-21 at 01:25 AM.
  Reply With Quote
04-20-21, 01:22 AM   #13
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by Taudier View Post
don't you know how to read code ?

and if you can do "/click MAP" you can do whatever in secure env

SDPhantom pointed you a way to toggle the map
here is a solution to always show it
i'm sure you can figure out a way to hide it
Like I said a couple of times, using /click is not what I'm after. My question was about opening the map via a custom slash command.

The answer is that what I'm after is not possible both because there is no secure handler template for custom slash commands (there could be one, but there isn't) and because ShowUIPanel is not accessible from a restricted environment (which it could be, but isn't).
  Reply With Quote
04-20-21, 01:41 AM   #14
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
The answer is that what I'm after is not possible both because there is no secure handler template for custom slash commands
you can, you have to remap the keyboard to a secure env, if you don't like /click

and because ShowUIPanel is not accessible from a restricted environment
wrong again, this is /click MiniMapWorldMapButton

Last edited by Taudier : 04-20-21 at 01:45 AM.
  Reply With Quote
04-20-21, 01:54 AM   #15
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by Taudier View Post
you can, you have to remap the keyboard to a secure env, if you don't like /click
I know that you can map a key to trigger a click which can be used to drive a secure button.

Unless I misunderstand, that does not somehow enable to me to call a protected function during combat using a custom slash command, which is, again, what my question was asking about, and which does not appear to be possible for the reasons others explained and that I mentioned a couple of times - which answers my question.

Last edited by samueldcorbin : 04-20-21 at 01:59 AM.
  Reply With Quote
04-20-21, 02:06 AM   #16
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
a slash command is just multiple buttons pressed

and most of the time, if your function is protected there is a secure trigger, this is the case for WorldMapFrame

Last edited by Taudier : 04-20-21 at 02:10 AM.
  Reply With Quote
04-20-21, 02:10 AM   #17
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by Taudier View Post
a slash command is just multiple buttons pressed
Assume I have a slash command /sam, and I want it to open the map, during combat. Can you show how I would go about doing that?
  Reply With Quote
04-20-21, 02:16 AM   #18
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
you create a button that SetBinding all your keyboard to dummy buttons

then your WrapScript your dummy buttons and you interpret the key pressed

all that because you don't like /click, which you could customise with buttons, or parameterize

Last edited by Taudier : 04-20-21 at 02:24 AM.
  Reply With Quote
04-20-21, 02:22 AM   #19
samueldcorbin
A Deviate Faerie Dragon
Join Date: Dec 2020
Posts: 14
Originally Posted by Taudier View Post
you create a button that SetBinding all your keyboard to dummy buttons

then your WrapScript your dummy buttons and you interpret the key pressed

all that because you don't like /click, which you could customise with buttons, or parameterize
I'm not sure I'm following what you mean. Can you show a simple example of doing this for /sam?

And it isn't "because I don't like /click" - it's because there are a half dozen other functions run from slash commands in this ~2000-line addon and I'd like the keep the interface for it uniform.

I am not sure what I did to warrant so much hostility.
  Reply With Quote
04-20-21, 02:58 AM   #20
Taudier
A Cyclonian
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 44
Originally Posted by samueldcorbin View Post
I'm not sure I'm following what you mean. Can you show a simple example of doing this for /sam?
I'm afraid there is no simple example


Originally Posted by samueldcorbin View Post
And it isn't "because I don't like /click" - it's because there are a half dozen other functions run from slash commands in this ~2000-line addon and I'd like the keep the interface for it uniform.
then you can create half dozen of buttons like the one I posted above
or thouhand if you have parameters
or use the btn option like : /click [btn:1] MAP
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Open Map From Slash Command

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