Get token handout image size?

If you have searched the other User Creations subforums and an answer to your question has not been found, please post here!

Moderators: dorpond, trevor, Azhrei, Gamerdude

Post Reply
User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Get token handout image size?

Post by Purzelkater »

I know I can get the token image size with getTokenNativeHeight() and getTokenNativeWidth(). But I want to get this for the assoziated handout image too, not the token itself.

I want to show the handout image on a frame, opend by a macro. So I would like to ajust the frame size based on the handout size.

Kind regards
from Purzelkater

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Get token handout image size?

Post by wolph42 »

ive implemented someones tool on the BoT (link in sig) . It allows you to set the size and choose you which image to use of the token

User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Re: Get token handout image size?

Post by Purzelkater »

Thank you, but I'm not sure if this works like I want it. If I'm right, I have to set the size by hand. But I want to get the size from the image itself.

I have tried to create a macro, replace the image of a (hidden) token with the image of the selected token handout. This works nicely.
Unfortunaly if I try to get the token native image size, I only get the old (original) size of the token, not the size of the newly set token image. So getTokenNativeWidth and getTokenNativeHeight are returning wrong values.

Code: Select all

[h: tokenName = token.name]

[h: handoutImageAssetId = getTokenHandout()]

[h: handoutTokenId = findToken("Handout", "Handouts")]

[h: setTokenImage(handoutImageAssetId, handoutTokenId, "Handouts")]

[h: handoutImageWidth = getTokenNativeWidth(handoutTokenId, "Handouts")]
[h: handoutImageHeight = getTokenNativeHeight(handoutTokenId, "Handouts")]

[h: frameParameters = "width="+handoutImageWidth+"; height="+handoutImageHeight+"; temporary=1; input=0; noframe=0"]

[frame(tokenName, frameParameters): {
    <img src='[r: handoutImageAssetId]'></img>	
}]

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Get token handout image size?

Post by wolph42 »

I see, its possible that you have a timing/concurrence issue. Have you tried breaking the macro with use of [input("junk")] after this line:

Code: Select all

[h: setTokenImage(handoutImageAssetId, handoutTokenId, "Handouts")]
and then see what turns up?

The input allows MT to resolve the earlier commands as sometimes that 'stuff' gets hold up until exit of the macro and is then executed...giving the wrong return in this case.
If that won't work too: then report it as a bug.

User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Re: Get token handout image size?

Post by Purzelkater »

I have tried to hold the macro with an input box but it doesn't work too - same issue.
Now I just have added 2 properties where I can insert the handout image size and read this properties to set the current frame size:

Code: Select all

[h: tokenName = token.name+" (Handout)"]
[h: handoutImageAssetId = getTokenHandout()]
[h: handoutImageWidth = getProperty("Handout Width")+12]
[h: handoutImageHeight = getProperty("Handout Height")+30]

[h: frameParameters = "width="+handoutImageWidth+"; height="+handoutImageHeight+"; temporary=1; input=0; noframe=0"]

[frame(tokenName, frameParameters): {
    <img src='[r: handoutImageAssetId]'></img>	
}]
It's not the most elegant way but it works. ^^

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

Re: Get token handout image size?

Post by aliasmask »

Looks good to me.


Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: Get token handout image size?

Post by Merudo »

The functions getTokenNativeWidth and getTokenNativeHeight return the native dimensions of the token, not of the image.

Using setTokenImage on a token does not change its native dimensions.

User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Re: Get token handout image size?

Post by Purzelkater »

Merudo wrote:
Fri Nov 22, 2019 5:31 pm
The functions getTokenNativeWidth and getTokenNativeHeight return the native dimensions of the token, not of the image.
Then why I get this values if I use this functions:
getTokenImageSize.png
getTokenImageSize.png (274.81 KiB) Viewed 6737 times

As you can see, I have used the standard map with 60 pixels per cell and add a map as a token. But getTokenNativeWidth and getTokenNativeHeight are returning the real image size of the shown token - 1829 x 1341 pixels - and not the token token.

From the wiki:
getTokenWidth() Function
• Introduced in version 1.5.1
Retrieves the token's native image width in pixels (native size).
You see "native image width"? So it should return the size of the image, not the token, I would expect,

Merudo wrote:
Fri Nov 22, 2019 5:31 pm
Using setTokenImage on a token does not change its native dimensions.
Yes and that's the problem. Because it should change the native dimensions too, beacuse the image has also changed.

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Get token handout image size?

Post by wolph42 »

I think your mixing things up, you have:
http://lmwcs.com/rptools/wiki/getTokenWidth
and
http://lmwcs.com/rptools/wiki/getTokenNativeWidth
first returns the current token size on map, the latter returns the native size of the image

this:
From the wiki:
getTokenWidth() Function
• Introduced in version 1.5.1
Retrieves the token's native image width in pixels (native size).
is probably an incorrect entry, it should have said: getTokenNativeWidth
getTokenWidth exists around 1.3 b88

User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Re: Get token handout image size?

Post by Purzelkater »

Yes, the wiki entry of getTokenNativeWidth has a wrong title (but getTokenNativeHeight is correct).
However, getTokenNativeWidth and getTokenNativeHeight are showing wrong values after setTokenImage (tested with 1.5.7 too)

Phergus
Deity
Posts: 7132
Joined: Fri May 12, 2006 8:56 pm
Location: Middle of Nowhere, NM
Contact:

Re: Get token handout image size?

Post by Phergus »

It's a big mess. Some changes were made in 1.5.1 with adding Reset Size to the token menu and the various sizes that are tracked inside of a token have gotten confused especially in regards to Native Size and such.

Post Reply

Return to “Requests for HELLLLP!”