Raoden's Quick'n'Dirty Token Manager

These are tools and utilities that make it easier to run games. This includes Lib: macro tokens dropped into MapTool to manage the game, a conversion file for CharacterTool to allow use in MapTool, or just about anything else you can think of -- except graphics with macros and anything specific to a particular campaign framework. Those are already covered by the Tilesets subforum and the Links and External Resources forum.

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

User avatar
Raoden
Dragon
Posts: 381
Joined: Fri Dec 18, 2009 2:33 am
Location: San Diego

Raoden's Quick'n'Dirty Token Manager

Post by Raoden »

07/06/10: v2.0 uploaded
New features:
  • New user interface, utilizing a frame instead of a dialog. Separate "tabs" in the frame for managing Properties and Macros. Frame is compatible with the new version of my Mood Manager that I'll be releasing soon.
  • JSON Editor hopefully works flexibly, finally.
  • JSON Editor can now edit the order of JSON Arrays, using little "up arrow" and "down arrow" links.
  • Like v1.4, should automatically adapt to your MapTool build when deleting unwanted properties or displaying capitalization of Property names.
07/02/10: v1.4 uploaded
New features: Should detect MapTool build automatically and adapt to new macros available subsequent to 1.3.b63.
In b64 and later builds, this means capitalization of token properties should now be preserved.
In b68 and later builds, this means erasing unwanted properties from the token no longer involves using a "Clone Token."

05/28/10: v1.3 uploaded.
New features: Rumble's Macro Deletion utility; Macro Import/Export functions by CoveredInFish and aliasmask. Links to all these new functions are available in the Property Editor frame.

05/28/10: v1.2 uploaded.
New feature: "delete" unwanted properties (including "hidden" properties) by copying most of a token's information over to a new token, but leaving out unwanted properties. Thank you for getting this started, CoveredInFish.

------------

OK, I wasn't planning to post this as an independent User Creation, as I know there are already some similar things floating around. But there's been some interest expressed in this tool, and as far as I know there isn't currently any other tool on this Forum that has all of this utility.

Instructions
  1. Download the attached token
  2. Place it in your campaign
  3. Copy the main macro -- the red one -- to Campaign Macros
  4. Select or impersonate on the token whose properties you want to edit
  5. Click on the new Edit Token Properties Campaign Macro
Features
  • Interface should be pretty self-explanatory
  • Accesses all of a token's properties, whether defined in Campaign Settings or "hidden"
  • Can work with token properties that use JSON structures (of any reasonable depth). To make a token property into a JSON, or to add a nested layer to an existing JSON, just enter {} or [] when prompted for a value of a property.
One thing I've noticed it can't do is change the order of elements in a JSON array. If such a feature would increase the utility significantly, let me know and I'll work on it.
Attachments
Token Manager v2.0.rptok
(56.75 KiB) Downloaded 1004 times
Last edited by Raoden on Tue Jul 06, 2010 4:41 am, edited 8 times in total.
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0


User avatar
Raoden
Dragon
Posts: 381
Joined: Fri Dec 18, 2009 2:33 am
Location: San Diego

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Raoden »

Thanks, CIF.

And, a screenshot.
Attachments
PropEditorDemo.PNG
PropEditorDemo.PNG (194.1 KiB) Viewed 14295 times
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Full Bleed »

Nice tool, thanks.

Could you distinguish between which properties are "Hidden"? Maybe make them display in italics if they are?


And since you put this tool together, I figure you might know the answer to this question... I understand that it's impossible to truly "delete" a hidden property (or any property) within MT. Has anyone made something that makes it easier to do that outside MT either directly with an RPTOK file or by selectively reading the right info from the xml file inside the RPTOK file?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
Raoden
Dragon
Posts: 381
Joined: Fri Dec 18, 2009 2:33 am
Location: San Diego

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Raoden »

Full Bleed wrote:Nice tool, thanks.

Could you distinguish between which properties are "Hidden"? Maybe make them display in italics if they are?
That's a good idea. I'll work on it.
And since you put this tool together, I figure you might know the answer to this question... I understand that it's impossible to truly "delete" a hidden property (or any property) within MT. Has anyone made something that makes it easier to do that outside MT either directly with an RPTOK file or by selectively reading the right info from the xml file inside the RPTOK file?
Nope, can't help you myself. I know nothing about XML (yet).
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Quick'n'Dirty Token Property Editing Dialog

Post by CoveredInFish »

Full Bleed wrote: I understand that it's impossible to truly "delete" a hidden property (or any property) within MT.
You could create a new token, copy and set all except the stuff you'd like to delete.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Azhrei »

AFAIK this is the only way to do it within MT.

I'm not inclined to work on fixing this myself, but if someone else wanted to create a patch I'd look at it.

I expect that 1.4 will use a completely different approach to properties (in terms of how they're managed internally) so to me there's not a compelling enough case.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Full Bleed »

CoveredInFish wrote:You could create a new token, copy and set all except the stuff you'd like to delete.
Is there a way to do this with a macro?

The I/O Macro you and Alias made helps with getting all the macros onto a new token, but moving over the other properties can be time consuming.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Quick'n'Dirty Token Property Editing Dialog

Post by CoveredInFish »

I have a macro that makes a complete copy. You'd have to create the UI to select properties to exclude.
duplicateToken

Code: Select all

[h: '<!-- get source and destination via user input -->']
[h: tokens = getTokens()]
[h: names = ""]
[h, foreach( id, tokens ): names = listAppend(names, getName(id))]

[h: status = input(
    strformat("srcIdx|%s|Select source|LIST", names), 
    strformat("destIdx|%s|Select destination|LIST", names)
)]
[h: abort(status)]
[h: assert( srcIdx != destIdx , "You must select different tokens.")]

[h: src = listGet(tokens, srcIdx)]
[h: dest = listGet(tokens, destIdx)]

[h: '<!-- set states -->']
[h: allStates = getTokenStates()]
[h, foreach(state, allStates): setState(state, getState(state, src), dest)]

[h: '<!-- set image -->']
[h, token(src): image = getTokenImage()] 
[h, token(dest): setTokenImage( image )]

[h: '<!-- copy properties -->']
[h: allProps = getPropertyNames(",", src)]
[h: excludeList = ""]
[h, foreach(prop, allProps), code: {
    [h, if(listFind(excludeList, prop)!=-1), code: {
       [h: setProperty(prop, getProperty(prop, src), dst)]
    };{}]
}]

[h: '<!-- misc  -->']
[h: setName(getName(src)+" copy", dest)]
[h: setGMName(getGMName(src), dest)]
[h: setLabel(getLabel(src), dest)]
[h, token(src): notes = getNotes()]
[h, token(dest): setNotes(notes)]
[h, token(src): notes = getGMNotes()]
[h, token(dest): setGMNotes(notes)]
[h, if( isPC(src)): setPC(dest); setNPC(dest)]
[h: setSize(getSize(src), dest)]
[h: setVisible(getVisible(src), dest)]
[h: setPropertyType(getPropertyType(src), dest)]

[h: '<!-- macros -->']
[h: allMacros = getMacros(",", src)]
[h, foreach( macro, allMacros ), code: {
    [h: indexes = getMacroIndexes(macro, ",", src)]
    [h, foreach( index, indexes ), code: {
        [h: props = getMacroProps(index, "json", src)]
        [h: createMacro(props, dest)]
    }]
}]
Token [r:getName(src)] copied. 

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Full Bleed »

CoveredInFish wrote:I have a macro that makes a complete copy. You'd have to create the UI to select properties to exclude.
I tried, but ran into problems with properties that had pipes in them and my UI failed. Too much trouble to figure it out.

How do I use the excludeList? I put some property names inside the quotes, separated with commas, and they still copied over. And, strangely, some other properties that I wanted to copy over didn't.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Quick'n'Dirty Token Property Editing Dialog

Post by CoveredInFish »

Hmm .. pipes in property names will be always a problem when you use input(). You could replace them with something and replace them back after the dialog.

The excludeList should be a string list of property names.

All properties retrieved by Wiki: getPropertyNames() should get copied. If Wiki: listFind() returns -1 for a prop vs the excludeList it skips setProperty.
I dont see where this would fail ...

If this topic keeps growing we should stop hijacking this thread :oops:

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Full Bleed »

CoveredInFish wrote:The excludeList should be a string list of property names.
Can't get it to work. Can you show me an example of what it should look like?

All properties retrieved by Wiki: getPropertyNames() should get copied. If Wiki: listFind() returns -1 for a prop vs the excludeList it skips setProperty.
I dont see where this would fail ...
It most definitely is not copying over *any* properties for me. The only properties showing on the new token are the defaults. Maybe I'm using it wrong. All I did was put the code into a macro in the Campaign Window. Run it. Selected the token I wantd to copy and the "blank." It says it copied... changed the name of the new token it in the popup. Selected a "blank" for the copy. It seemed to copy everything over by the properties and the vision type.

If this topic keeps growing we should stop hijacking this thread :oops:
Well, I figure if I keep bumping the topic enough, maybe Raoden will think it's a cool idea to turn his "Edit Token Properties" macro into an "Copy/Edit Token Properties" macro by incorporating your code. ;)

But you can go ahead and start a thread with your duplicateToken as a drop-in if you'd like. We can move our discussion there.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
CoveredInFish
Demigod
Posts: 3104
Joined: Mon Jun 29, 2009 10:37 am
Location: Germany
Contact:

Re: Quick'n'Dirty Token Property Editing Dialog

Post by CoveredInFish »

You used it right but i wrote it wrong.

Fixed (it would have copied only props in the excludeList) and added dialog for selecting properties to skip/exclude.
fixed code

Code: Select all

[h: '<!-- get source and destination via user input -->']
[h: tokens = getTokens()]
[h: names = ""]
[h, foreach( id, tokens ): names = listAppend(names, getName(id))]

[h: status = input(
    strformat("srcIdx|%s|Select source|LIST", names), 
    strformat("destIdx|%s|Select destination|LIST", names)
)]
[h: abort(status)]
[h: assert( srcIdx != destIdx ,"You must select different tokens.")]

[h: src = listGet(tokens, srcIdx)]
[h: dest = listGet(tokens, destIdx)]

[h: '<!-- set states -->']
[h: allStates = getTokenStates()]
[h, foreach(state, allStates): setState(state, getState(state, src), dest)]

[h: '<!-- set image -->']
[h, token(src): image = getTokenImage()] 
[h, token(dest): setTokenImage( image )]

[h: '<!-- copy properties -->']
[h: allProps = getPropertyNames(",", src)]

[h: '<!-- build dialog -->']
[h: fields = ""]
[h, foreach(prop, allProps): fields = json.append(fields, strformat("exclude%s|0|%s|CHECK", prop, prop))]
[h: status = input(json.toList(fields, "##"))]
[h: abort(status)]
[h: excludeList = ""]
[h, foreach(prop, allProps), code: {
    [h, if(eval("exclude"+prop)==1): excludeList = listAppend(excludeList, prop)]
}]

[h, foreach(prop, allProps), code: {
    [h, if(listFind(excludeList, prop)==-1), code: {
       [h: setProperty(prop, getProperty(prop, src), dest)]
    };{}]
}]

[h: '<!-- misc  -->']
[h: setName(getName(src)+" copy", dest)]
[h: setGMName(getGMName(src), dest)]
[h: setLabel(getLabel(src), dest)]
[h, token(src): notes = getNotes()]
[h, token(dest): setNotes(notes)]
[h, token(src): notes = getGMNotes()]
[h, token(dest): setGMNotes(notes)]
[h, if( isPC(src)): setPC(dest); setNPC(dest)]
[h: setSize(getSize(src), dest)]
[h: setVisible(getVisible(src), dest)]
[h: setPropertyType(getPropertyType(src), dest)]

[h: '<!-- macros -->']
[h: allMacros = getMacros(",", src)]
[h, foreach( macro, allMacros ), code: {
    [h: indexes = getMacroIndexes(macro, ",", src)]
    [h, foreach( index, indexes ), code: {
        [h: props = getMacroProps(index, "json", src)]
        [h: createMacro(props, dest)]
    }]
}]
 

User avatar
Raoden
Dragon
Posts: 381
Joined: Fri Dec 18, 2009 2:33 am
Location: San Diego

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Raoden »

Full Bleed wrote: Well, I figure if I keep bumping the topic enough, maybe Raoden will think it's a cool idea to turn his "Edit Token Properties" macro into an "Copy/Edit Token Properties" macro by incorporating your code. ;)
Sure, I'm fine doing that, as long as CIF does all the hard work. :wink:
"Fairy tales do not tell children the dragons exist. Children already know that dragons exist. Fairy tales tell children the dragons can be killed."
- G. K. Chesterton

Wonderful HTML/CSS reference * Color Manager * Token Manager 2.0

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Quick'n'Dirty Token Property Editing Dialog

Post by Full Bleed »

CoveredInFish wrote:You used it right but i wrote it wrong.

Fixed (it would have copied only props in the excludeList) and added dialog for selecting properties to skip/exclude.
Dangit. Still can't get this to work. I got a prompt for a property value:

Code: Select all

value for excludedamage
I think the problem is that I had a white space in a property called "Damage Reduction." I changed the name in Campaign properties but, of course, it is already on the token incorrectly.

Any way to deal with that? Or am I going to have to go into xml?

Oh yeah, and thanks for the check boxes! :)

Raoden wrote:Sure, I'm fine doing that, as long as CIF does all the hard work. :wink:
Looks like the hard work at this point would be setting up the UI.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “Drop-In Macro Resources”