RPTools.net

Discussion and Support

Skip to content

It is currently Fri Nov 24, 2017 11:11 pm 






Reply to topic  [ 9 posts ] 

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Dragon
 
Joined: Wed Jul 03, 2013 4:58 am
Posts: 350
 Post subject: Running Macros from Token Right Click Context Menu
PostPosted: Wed Jul 10, 2013 7:36 am 
Normally when a Token is selected, the right click context menu provides access to a lot of functionality including a macros sub-menu from which macros can be executed (instead of having to select the macro from a Campaign or Selected window).

This is great and in my slightly modified MapTools, more geared to playing card games, I have added these macros into the root of the context menu and hid most of the other options so that right clicking on a token mostly just provides token macros for operating the token (such as flipping a card token over, placing it into the player's hand, and so on). Works great.

However, in the unmodified MapTools when multiple tokens are selected, the macro sub-menu disappears from the token right click context menu.

Is there a reason for this? When multiple tokens are selected the Selected window shows all common macros and then the macros for individual tokens. In my opinion, implementing either as the right click context menu macro sub-menu would have been better than making no macros available from the macro sub-menu.

I looked into the code, because I want this option active in my modified MapTools version, and found that it was a very easy fix. The code does a check to see if more than one token is selected in which case it returns from the "create macro list" function without adding any macros. I disabled the check and, as expected, got the macro sub-menu in all cases. I tried it and it processed the macro on all selected tokens. The only reason why I can think that this might have been disabled is because it seems to process the macro on all selected tokens but, I am guessing, the macro list is determined by the selected token...as such if the macro does not exist on the other selected tokens it might generate an error. I did not try that yet.

Does anyone know why the macro sub-menu was removed when multiple tokens are selected? Is it for the above mentioned reason or is there a different reason why I should not enable this functionality?

_________________
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Wed Jul 10, 2013 3:18 pm 
Lord.Ashes wrote:
Normally when a Token is selected, the right click context menu provides access to a lot of functionality including a macros sub-menu from which macros can be executed (instead of having to select the macro from a Campaign or Selected window).

This is great and in my slightly modified MapTools, more geared to playing card games, I have added these macros into the root of the context menu and hid most of the other options so that right clicking on a token mostly just provides token macros for operating the token (such as flipping a card token over, placing it into the player's hand, and so on). Works great.

However, in the unmodified MapTools when multiple tokens are selected, the macro sub-menu disappears from the token right click context menu.

Is there a reason for this? When multiple tokens are selected the Selected window shows all common macros and then the macros for individual tokens. In my opinion, implementing either as the right click context menu macro sub-menu would have been better than making no macros available from the macro sub-menu.

I looked into the code, because I want this option active in my modified MapTools version, and found that it was a very easy fix. The code does a check to see if more than one token is selected in which case it returns from the "create macro list" function without adding any macros. I disabled the check and, as expected, got the macro sub-menu in all cases. I tried it and it processed the macro on all selected tokens. The only reason why I can think that this might have been disabled is because it seems to process the macro on all selected tokens but, I am guessing, the macro list is determined by the selected token...as such if the macro does not exist on the other selected tokens it might generate an error. I did not try that yet.

Does anyone know why the macro sub-menu was removed when multiple tokens are selected? Is it for the above mentioned reason or is there a different reason why I should not enable this functionality?


The problem is that macros run that way then have no way to determine which token is in context. Not that it could not be coded to figure it out and run them one after another, but that's work that won't be done in 1.3 by the core team.

There is also the issue of security to keep in mind. How would you like if someone ran a macro on YOUR token.

_________________
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12103
Location: Tampa, FL
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Thu Jul 11, 2013 12:06 am 
I think the macros submenu of the token work like the Selection Panel does: only macros that are common across all tokens will appear in the context menu. When you select one, it iterates over each token calling the macro. Each time through the loop, the next token is impersonated, the macro is run, then the impersonation is turned off. Then it goes to the next token.


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Jul 03, 2013 4:58 am
Posts: 350
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Thu Jul 11, 2013 3:14 am 
jfrazierjr wrote:
The problem is that macros run that way then have no way to determine which token is in context.


I would respectively disagree...If I am selecting the macro from a token then *that* token should be the token in context.

jfrazierjr wrote:
Not that it could not be coded to figure it out and run them one after another, but that's work that won't be done in 1.3 by the core team.


Actually it seems that this work is already done...I have checked out MapTools source code to do a little modification for my own purpose...I am using MapTools for Card Game playing and thus I modded MapTools to hide most options in the Token context menu and instead bring the token macros to the root level of the token context menu. This basically means that when the player clicks on a token (in this case usually card tokens) they have easy access to the token's macros (which implement things like flipping the card, taking it into your hand, etc). In any case, I did look at this issue macros from the token context menu issue because when I selected multiple tokens (cards) I was not able to select group options like Stack or Shuffle due to this issue. I found that in the code there is a simple check to return no macros if more than one token is selected. When I uncommented this check,
I was able to access the macros (I am guessing the macros for the selected token) via the context menu. I expected this to execute the macro on only the current token but actually it did execute it on all the selected macros (I should not that my macros use the Apply To All Selected option). So the code is already there.

I think that the reason why it was commented out is that there could be an issue if the player executes a macro on a bunch of selected tokens of which at least one does not support that macro. I did not get a chance to see what happens when I do that.

jfrazierjr wrote:
There is also the issue of security to keep in mind. How would you like if someone ran a macro on YOUR token.


No issue there if you are using strict token ownership. If this is a concern then this option could be activated only when the Strict Ownership option is on.

_________________
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Jul 03, 2013 4:58 am
Posts: 350
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Thu Jul 11, 2013 3:18 am 
Azhrei wrote:
I think the macros submenu of the token work like the Selection Panel does: only macros that are common across all tokens will appear in the context menu. When you select one, it iterates over each token calling the macro. Each time through the loop, the next token is impersonated, the macro is run, then the impersonation is turned off. Then it goes to the next token.


Not as far as I can see. I have many tokens (cards) which all share the exact same macros. However, when I select multiple of these tokens, I get the Common macros (i.e. all of the macros) shown in the Selected Windows (along with the macros for each individual token) but I do not get any macros in the token right click context menu.

As I said in my previous post, I looked at the source code and there is specifically a check for multiple selected tokens in which case the function returns no macros to the right context menu function.

_________________
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Thu Jul 11, 2013 9:01 am 
What I was trying to say was what Azhrei said better, which is what should it do if you select multiple tokens?

Display All macros across all tokens even one or more don't have the macro
Display only the common subset
What happens when you ALSO select a token you do NOT own? With the former, that's seems really bad. With the latter, it's a bit better, but then the macro engine now has to also check ownership of the token to make sure if you run a macro it's allowed on each token that was selected. The selection panel handles this a bit differently since (as far as I know, it filters out tokens that you don't own for displaying he macro's AND it handles common vs exclusive macros in a different way on the panel(for those that you do own).

_________________
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Jul 03, 2013 4:58 am
Posts: 350
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Sun Jul 14, 2013 6:21 am 
jfrazierjr wrote:
What I was trying to say was what Azhrei said better, which is what should it do if you select multiple tokens?

Display All macros across all tokens even one or more don't have the macro
Display only the common subset
What happens when you ALSO select a token you do NOT own? With the former, that's seems really bad. With the latter, it's a bit better, but then the macro engine now has to also check ownership of the token to make sure if you run a macro it's allowed on each token that was selected. The selection panel handles this a bit differently since (as far as I know, it filters out tokens that you don't own for displaying he macro's AND it handles common vs exclusive macros in a different way on the panel(for those that you do own).


Good point. Using my modified MapTools, the campaigns are all run with Strict Token Ownership and Visibility To Owners Only so the last case can not occur bu you are correct that for the general MapTools this would need to be considered (and might be the reason why the function was removed when more than one token is selected).

_________________
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Sep 11, 2007 6:31 pm
Posts: 5412
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Sun Jul 14, 2013 12:02 pm 
Lord.Ashes wrote:
jfrazierjr wrote:
What I was trying to say was what Azhrei said better, which is what should it do if you select multiple tokens?

Display All macros across all tokens even one or more don't have the macro
Display only the common subset
What happens when you ALSO select a token you do NOT own? With the former, that's seems really bad. With the latter, it's a bit better, but then the macro engine now has to also check ownership of the token to make sure if you run a macro it's allowed on each token that was selected. The selection panel handles this a bit differently since (as far as I know, it filters out tokens that you don't own for displaying he macro's AND it handles common vs exclusive macros in a different way on the panel(for those that you do own).


Good point. Using my modified MapTools, the campaigns are all run with Strict Token Ownership and Visibility To Owners Only so the last case can not occur bu you are correct that for the general MapTools this would need to be considered (and might be the reason why the function was removed when more than one token is selected).


Since you have your own MapTool build, it should not be extremely hard to modify the context menu code and build in the support for it. You just have to check if the player selecting the token owns the token(s) and then grab the macros for only the ones he owns. Do all tokens have the exact same macros, or does each one have something different? That's the big issue to figure out, so good luck.

_________________
I save all my Campaign Files to DropBox. Not only can I access a campaign file from pretty much any OS that will run Maptool(Win,OSX, linux), but each file is versioned, so if something goes crazy wild, I can always roll back to a previous version of the same file.

Get your Dropbox 2GB via my referral link, and as a bonus, I get an extra 250 MB of space. Even if you don't don't use my link, I still enthusiastically recommend Dropbox..


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Wed Jul 03, 2013 4:58 am
Posts: 350
 Post subject: Re: Running Macros from Token Right Click Context Menu
PostPosted: Tue Jul 16, 2013 4:23 am 
jfrazierjr wrote:
Lord.Ashes wrote:
jfrazierjr wrote:
What I was trying to say was what Azhrei said better, which is what should it do if you select multiple tokens?

Display All macros across all tokens even one or more don't have the macro
Display only the common subset
What happens when you ALSO select a token you do NOT own? With the former, that's seems really bad. With the latter, it's a bit better, but then the macro engine now has to also check ownership of the token to make sure if you run a macro it's allowed on each token that was selected. The selection panel handles this a bit differently since (as far as I know, it filters out tokens that you don't own for displaying he macro's AND it handles common vs exclusive macros in a different way on the panel(for those that you do own).


Good point. Using my modified MapTools, the campaigns are all run with Strict Token Ownership and Visibility To Owners Only so the last case can not occur bu you are correct that for the general MapTools this would need to be considered (and might be the reason why the function was removed when more than one token is selected).


Since you have your own MapTool build, it should not be extremely hard to modify the context menu code and build in the support for it. You just have to check if the player selecting the token owns the token(s) and then grab the macros for only the ones he owns. Do all tokens have the exact same macros, or does each one have something different? That's the big issue to figure out, so good luck.


Agreed. I currently took out the check for that the official MapTools version does for hiding these macros from the right context menu when more than one token is selected. But you are quite correct that I need to ensure that this will not generate errors when an incorrect token (i.e. a token that does not share the macro with others) is selected. The current code seems to fill the macro list based on the currently selected token as opposed to the macros common to all selected macros. For my use this does not matter because the tokens that it will normally be used on, in my case, are tokens which all share the same macros (i.e. card tokens for my card games). But I will have, in some campaigns (card games), additional tokens, such as those representing players, which will not have those macros...so I do need to add some protection if those are included in the selection accidentally.

Update:

I did some testing and with the check removed, when I run a macro on multiple selected objects that at least one of the selected objects does not have, it generates an error in the chat window but seems to carry out the macro on all selected tokens that do have the macro. This means that for my purpose (we don't use the chat window) its fine as is. Yes, eventually I will look into trying to actually avoid the error in the chat window but for now it works...it basically reports a error in the body of the macro. I tried to put a check in the beginning of the macro to check if the token is a valid token for that operation (i.e. in my implementation all card tokens, which are the only ones that uses these particular macros, are all of a PropertyType "Card") but the check never ran for the token which didn't include the macro...so it would have to be a code fix as opposed to a macro fix.

_________________
"We often compare ourselves to the U.S. and often they come out the best,
but they only have the right to bare arms, while we have the right to bare breasts"
The Right To Bare Breasts by Bowser & Blue


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 9 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 2 guests





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman