Token Manager "Clone" confusion

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Token Manager "Clone" confusion

Post by silbrulf »

What I am trying to do is take apart Token manager a bit. I like the Frame, I like the fact that it can get my properties and display the values, but I dont need a page with macros. I would like to replace the Macros page with a "getNotes" page, and make it so that the Properties appear in the order I have them in Campaign properties. This is ultimately for my framework, so id rather it use a system like Token Manager than for every DM having to recode for their token properties setup.
My confusion comes from the fact that i cant figure out which of the macros on the Token Manager does what. Mainly because I dont quite get JSON yet.

Quick Edit: This bit of code is what I was originally working with, and other than "getProperty(name)=" it shows a bit of what im trying to do with the properties, i hope.

Code: Select all

[frame (getName()): {
	[h: names = getPropertyNames()]
	[foreach(name, names, "<br>"): getProperty(name)]
}]
Last edited by silbrulf on Tue Mar 19, 2019 2:35 am, edited 2 times in total.
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

Code: Select all

@@ @mainFrame.Tokens
[h: data = macro.args]
[h: panelTabs = json.append( '[]', "Properties", "Macros" )]
[h: panelName = "Token Manager"]
...
If you remove ,"Macros" this will essentially remove the tab.

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

@Aliasmask, I made an edit to somewhat clarify my intent the same time you were answering... as for the removing the tab, its more that id rather have the tabs purpose changed to showing the notes on a token via the "getNotes" function
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

Looks like you would need to create a macro called subFrame.Tokens.Notes, add your html and code in there to show token notes and change the above "Macros" to "Notes".

For example:

Code: Select all

<!-- subFrame.Tokens.Notes -->
[h: id = r.currentToken( macro.args )]

[ if( id == "" ), code: {
	<h1>No Token Targeted</h1>
}; {
	[h: switchToken( id )]

	<h1>Notes</h1>
	<h2>[r: getName()]</h2>
	
	[R: getNotes()]
}]

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

That helps, and looking at that, it helped solve another issue i had set aside out of frustration... now im just stuck on how to make the Properties show up in the right order and not in alphabetical (with "HD" showing up at the top... there is no "HD" property...), or is that even possible? I havent seen anything about ordering the properties on the wiki
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

I would create a list of properties in the order you want and loop through rather than using the getMatchingProperties function for the list or properties.

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

aliasmask wrote:
Tue Mar 19, 2019 9:53 am
I would create a list of properties in the order you want and loop through rather than using the getMatchingProperties function for the list or properties.
Can that work as a generic function? If I use one set of properties and someone else uses a different set, could it be made to be equally compatible for either, or is that something that just isnt possible with the tools at hand?

Im looking through the wiki now, but itll take a day before it clicks enough to answer that myself; im a bit slow where code is concerned...
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

Yes you could. I would base it off the token type name.

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

aliasmask wrote:
Tue Mar 19, 2019 11:16 pm
Yes you could. I would base it off the token type name.
My work atm is a bit overcomplex until i can work it out a bit better (plus throwing errors, but i need to work it out myself or i wont learn...) but with the long way im doing it, using getProperties() to create a first string that gets reordered in another string, would it be

Code: Select all

getProperties("NPCombat")
?
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

When a token is added to a campaign it inherits the currently defined properties of the current campaign. These properties are persistent in the token even if the properties are subsequently removed from the campaign. Properties that have been removed from the campaign are no longer editable via the Edit Token dialog but they are still present on the token and may be read and set with getProperty() and setProperty() respectively. To get all properties defined on a token, including those removed from the campaign, use getPropertyNames(). To see only the currently defined properties for the campaign, use getAllPropertyNames().

Code: Select all

[H: allPropNames = getAllPropertyNames(getPropertyType(currentToken()),"json")]
[H: allPropNames = json.sort(allPropNames,"a")]
[R: json.toList(allPropNames,"<BR>")]

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

i feel stupid and am now trying to read all through the wiki to see what i missed... I dropped the second line of that to see what would happen (learning by trial, error, and expirimentation) and that accomplished exactly what i wanted. Still getting an "H" or "HD" attiribute that doesnt exist, but that might just need a clean token to start from.
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: Token Manager "Clone" confusion

Post by aliasmask »

Well, the prop name list is in the order of the token type, so if that's what you want then no need to sort or reorganize.

I assume H or HD is a hidden property on the token. If you're using getAllPropertyNames() hidden properties shouldn't show up. Let me know if it does and we can do a bug report.

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: Token Manager "Clone" confusion

Post by silbrulf »

aliasmask wrote:
Fri Mar 22, 2019 6:15 am
Well, the prop name list is in the order of the token type, so if that's what you want then no need to sort or reorganize.

I assume H or HD is a hidden property on the token. If you're using getAllPropertyNames() hidden properties shouldn't show up. Let me know if it does and we can do a bug report.
alright. i reopened the maptool last night and the H was gone... might have just been a temporary glitch, since i cant replicate it now.
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

Post Reply

Return to “MapTool”