Question about getTokenHandout macro command

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
TheIneffableCheese
Cave Troll
Posts: 64
Joined: Sun Mar 22, 2015 3:57 pm

Question about getTokenHandout macro command

Post by TheIneffableCheese »

I have a statblock macro that creates a frame and calls on the contents of the GM Notes field. I put the token's statblock in HTML in the note field, and the frame renders it for display. Works great.

Recently I realized that in some cases when using published modules it would actually be easier to grab an image of some statblocks rather than taking the time to copy and reformat the (always messed up) text from a PDF. If the code in the GM notes calls on the image on the local drive it works fine:

Code: Select all

<html>
<body>
<img src=file:///C:/Users/me/PathToFile/StatBlock.png></img>
</body>
</html>
Then I thought it would be nice to make the token more self contained by saving the statblock image as a Handout. I tried calling on it like this:

Code: Select all

<html>
<body>
<img src='[r:getTokenHandout()]'></img>
</body>
</html>
And it comes back with a big red "X" graphic
Screenshot 2021-01-23 205621.png
Screenshot 2021-01-23 205621.png (15.3 KiB) Viewed 3496 times
any ideas what I'm doing wrong?

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Question about getTokenHandout macro command

Post by aliasmask »

Depending on how the macro is called you have to make sure there is a current token impersonated, ie currentToken() isn't blank. You can use switchToken(), getSelected() or check the apply to selected token checkbox.

User avatar
TheIneffableCheese
Cave Troll
Posts: 64
Joined: Sun Mar 22, 2015 3:57 pm

Re: Question about getTokenHandout macro command

Post by TheIneffableCheese »

It's been over five years since I first set up these macros, so I've been going back through them.

I've traced through everything, and I cannot figure out where I should add a call to disambiguate the current token.

The campaign macro "Show Statblock" is pretty simple, and it calls on a couple of library macros to do the heavy lifting. I've double checked all of these and each macro below has "Apply to Selected Tokens" checked on the Details tab.

Code: Select all

[h: assert(isGM(),"This macro is for GM use only.",0)]
[h, macro("openStatblock@Lib:jctStatblock"):1]
openStatblock@Lib is as follows:

Code: Select all

[h: link = macroLinkText("openStatblock@Lib:jctStatblock", "none")]

[frame("Statblock"): {
<html>
<head>
<link rel="onChangeSelection" type="macro" href="[r:link]">
</head>
<body>
[r, macro("statblock@Lib:jctStatblock"): getSelected(id)]
</body>
</html>
}]
Finally, statblock@Lib is this:

Code: Select all

[h: id = macro.args]
[r, if(listCount(id)!=1), code: {};{

[h: switchToken(id)]
[h: statblock = getGMNotes()]
[r: statblock]

}]
For statblocks fully written in HTML in the GM notes, or for the simple HTML that calls on a locally stored image file, the contents of the Statblock frame that is created changes automatically whenever a new token is selected. It is just a problem when the HTML tries to reference the Handout using the getTokenHandout macro function.

If I can only get it to work by referencing locally stored images that is not the end of the world - it would just be way easier to keep the tokens self-contained and have a piece of HTML code that can always be inserted to the GM Notes when an image is being used.

Post Reply

Return to “Macros”