I have been able to create a macro that copies a token and can place it x number of spaces.
However I am looking to copy a token and place it in the middle of my current view. Any thoughts?
Copy and Place Token
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: Copy and Place Token
Never tried, but i think the Wiki: goto() function might be of help.
Roses are grey, violets are grey...I'm dead and colorblind!
Re: Copy and Place Token
getViewCenter may be what you want.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Kobold
- Posts: 9
- Joined: Thu Mar 31, 2022 11:21 pm
Re: Copy and Place Token
Alias, you have me on the right track...
getViewCenter gives me: centerX=1754,centerY=1159; and when I run the above, it opens dialogue boxes asking for values for centerX and centerY.
How do I get the coordinates out of getViewCenter and into moveToken?
Code: Select all
[H: id = copyToken("Hero")] <!-- copies token and gets id -->
[h:selectTokens(id)] <!-- selects the new token -->
[h:switchToken(getSelected())] <!-- impersonates the token so it can be moved -->
[h: setVisible(0, id)] <!-- hides token from players -->
[h: location = getViewCenter()] <!-- gets coordinates for center of the display -->
[h: moveToken(centerX, centerY)] <!-- moves the token to center of display -->
How do I get the coordinates out of getViewCenter and into moveToken?
Re: Copy and Place Token
Code: Select all
[H: json.toVars(getViewCenter(1, "json"))]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
-
- Kobold
- Posts: 9
- Joined: Thu Mar 31, 2022 11:21 pm
Re: Copy and Place Token
This works so well. Thank you so much!
Final macro:
Final macro:
Code: Select all
[h: id = copyToken("Hero")] <!-- copies token and gets id -->
[h:selectTokens(id)] <!-- selects the new token -->
[h:switchToken(getSelected())] <!-- impersonates the token so it can be moved -->
[h: setVisible(0, id)] <!-- hides token from players -->
[h: location = getViewCenter()] <!-- gets coordinates for center of the display -->
[H: json.toVars(getViewCenter(1, "json"))] <!-- converts coordinates to variables -->
[h: moveToken(centerX, centerY)] <!-- moves the token to center of display -->