Can someone tell me how to write a macro with a dialog (I currently use "input"), where I do the following:
1. Select tokens.
2. Click the button to invoke the macro.
3. Dialog pops up, I enter data, and click OK.
4. Update the selected tokens.
Problem: What is the best practice to use to stop the macro from being invoked for each selected token?
One Dialog - Apply To Many Selected Tokens?
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
-
- Cave Troll
- Posts: 43
- Joined: Sun Jan 06, 2019 12:29 pm
Re: One Dialog - Apply To Many Selected Tokens?
Writing an HTML form is its own issue and wolph42 has a tutorial in his signature, but the macro you run will have Apply to Selected unchecked. Then you'll use getSelected() in your code to loop through the tokens to make the changes. This is the way to have the code run once rather than on each token.
I personally would probably still use the input() function for data entry because its so easy, but if you want a dialog to stick around then the html form is the way to go.
The one real issue you may have is permissions. If this is a macro used by players then they may be able to update tokens they're not supposed to update. User isOwner() or isOwnedByAll() is one way to filter out tokens not owned by the player. Or you can limit the whole macro to GM only with isGM().
I personally would probably still use the input() function for data entry because its so easy, but if you want a dialog to stick around then the html form is the way to go.
The one real issue you may have is permissions. If this is a macro used by players then they may be able to update tokens they're not supposed to update. User isOwner() or isOwnedByAll() is one way to filter out tokens not owned by the player. Or you can limit the whole macro to GM only with isGM().
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Cave Troll
- Posts: 43
- Joined: Sun Jan 06, 2019 12:29 pm
Re: One Dialog - Apply To Many Selected Tokens?
Thank you very much. Yes, I use input for my dialogs. Maybe, I'll try an HTML version someday when I'm further along. Right now, function is more important than beauty.aliasmask wrote: ↑Wed May 15, 2019 6:36 amWriting an HTML form is its own issue and wolph42 has a tutorial in his signature, but the macro you run will have Apply to Selected unchecked. Then you'll use getSelected() in your code to loop through the tokens to make the changes. This is the way to have the code run once rather than on each token.
I personally would probably still use the input() function for data entry because its so easy, but if you want a dialog to stick around then the html form is the way to go.
The one real issue you may have is permissions. If this is a macro used by players then they may be able to update tokens they're not supposed to update. User isOwner() or isOwnedByAll() is one way to filter out tokens not owned by the player. Or you can limit the whole macro to GM only with isGM().
- metatheurgist
- Dragon
- Posts: 350
- Joined: Mon Oct 26, 2009 5:51 am