It happens quite often I select a large group of tokens, and run a very simple macro. Perhaps this one:
[h: setProperty("baseHpFormula", swgetforuma)]
And it asks me for input for every macro. But I have selected 10 macros, and the input is the same for every one of them.. That's why I selected 10 macros.
To my way of thinking, I would just set swgetforuma to a global variable, so it would ask once, and then not ask again for each token selected..
Of course, this will not work unless I can UNSET it after every group use..
Basically, what I want is to do is select a bunch of tokens that all have the same macro, use that macro, and it ask me for input once, and then have it set the property on every token selected.
Possible? Other ways to do this?
Global variables... Or a way to use the same input on multiple tokens.
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
-
- Giant
- Posts: 192
- Joined: Mon Apr 11, 2011 8:11 pm
Re: Global variables... Or a way to use the same input on multiple tokens.
yes, uncheck "Apply to Selected" because that will run the macro separately on each token. Now you create your own loop in the macro code, the process will be something like this
You may want to filter the tokenIds because it will apply to owned and unowned tokens selected, but sometimes that's okay.
Code: Select all
[H: tokenIds = getSelected()]
<!-- do stuff like get user input -->
[H, foreach(id,tokenIds), code: {
[H: switchToken(id)]
<!-- do the stuff that applies to all the tokens -->
}]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Giant
- Posts: 192
- Joined: Mon Apr 11, 2011 8:11 pm
Re: Global variables... Or a way to use the same input on multiple tokens.
So that means they would need to be global or GM macros rather then token macros I am assuming?
Re: Global variables... Or a way to use the same input on multiple tokens.
Correct, putting the macro in the Campaign Window which would reference a macro on a lib token is the typical way.Shadow Wizard wrote: ↑Sun Jul 10, 2022 9:32 amSo that means they would need to be global or GM macros rather then token macros I am assuming?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools