Get token handout image size?
Moderators: dorpond, trevor, Azhrei, Gamerdude
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Get token handout image size?
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
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
Re: Get token handout image size?
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
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Re: Get token handout image size?
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.
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>
}]
Re: Get token handout image size?
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:
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.
Code: Select all
[h: setTokenImage(handoutImageAssetId, handoutTokenId, "Handouts")]
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.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Re: Get token handout image size?
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:
It's not the most elegant way but it works. ^^
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>
}]
Re: Get token handout image size?
Looks good to me.
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Get token handout image size?
ik it works...
still weird the other method doesn't!
still weird the other method doesn't!
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Get token handout image size?
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.
Using setTokenImage on a token does not change its native dimensions.
MT Framework: Call of Cthulhu 7th fork, D&D 5e Spell Library
MT Scenario: Uncle Timothy's Will.
MT Utilities: Handouts, VBL Move Block, Date.
MT Scenario: Uncle Timothy's Will.
MT Utilities: Handouts, VBL Move Block, Date.
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Re: Get token handout image size?
Then why I get this values if I use this functions:
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:
You see "native image width"? So it should return the size of the image, not the token, I would expect,getTokenWidth() Function
• Introduced in version 1.5.1
Retrieves the token's native image width in pixels (native size).
Yes and that's the problem. Because it should change the native dimensions too, beacuse the image has also changed.
Re: Get token handout image size?
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:
getTokenWidth exists around 1.3 b88
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:
is probably an incorrect entry, it should have said: getTokenNativeWidthFrom the wiki:
getTokenWidth() Function
• Introduced in version 1.5.1
Retrieves the token's native image width in pixels (native size).
getTokenWidth exists around 1.3 b88
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Re: Get token handout image size?
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)
However, getTokenNativeWidth and getTokenNativeHeight are showing wrong values after setTokenImage (tested with 1.5.7 too)
Re: Get token handout image size?
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.