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
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Quick'n'Dirty Token Property Editing Dialog

Post by mfrizzell »

yeah, I believe that token was created in b64. I'll check out the single quotes and see what happens, thanks for looking at it for me.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

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 »

Yes, the properties.xml indicates it was created in b64. So don't expect it to load in older versions. (It might, but it's not guaranteed.)
mfrizzell wrote:But when I dropped a token on there that was heavy with hidden properties and added properties it failed to read it with the following error:

Unknown property type Enhanced in function getAllPropertyNames

I could attach the token if you want to look at it.

Edit: Attatched the token, thanks for taking a look.
That error message is because you have a token with the "Enhanced" property type and that property type is not defined in your campaign properties. For such a token you should open it and visit the Config tab, where the code will check the property type and set it to Basic (since Enhanced doesn't exist).

(At least, I think it will reset it to Basic. :?)

The property type doesn't immediately get reset because you could be dropping a bunch of tokens and then decide you want to add the Enhanced property type! It'd be a bummer to have to go back to each token and change it's property type back to Enhanced if they were automatically changed to Basic...

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 »

Hmmm ... then why doesnt it throw an error if if i drop that token in a new/empty/fresh campaign and type into the chat

Code: Select all

[r:getAllPropertyNames()]
i wonder, because that works fine and gives a list of the *basic*-set properties. If i edit the token *basic* is what set before and after the chat command was executed.

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 »

CoveredInFish wrote:Hmmm ... then why doesnt it throw an error if if i drop that token in a new/empty/fresh campaign [...]
Did the token have a property type that doesn't exist in the new campaign?

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: Quick'n'Dirty Token Property Editing Dialog

Post by mfrizzell »

Azhrei wrote:
CoveredInFish wrote:Hmmm ... then why doesnt it throw an error if if i drop that token in a new/empty/fresh campaign [...]
Did the token have a property type that doesn't exist in the new campaign?
Yes at one time there was an enhanced campaign property group but no longer.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

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 »

I finally tweaked CIF's macro, made a couple improvements, and added it to the Property Editor token. The new PropertyEditor token is now uploaded to the OP of this thread as version 1.2.

It may be a little late in coming, since all of this may get much simpler as soon as this evening, when Azhrei patches Wiki: removeProperty(). Oh well.
Full Bleed wrote:I do have a couple other requests if you're interested in developing the tool further...

1) Change the "Check properties that you want to exclude" terminology to be "Remove Properties you don't want to Copy" and make all the boxes checked by default. I think it's a little more intuitive to see the checkmarks next to what I want to keep... but that may just be me.
I agree that this is a more intuitive interface, and it is included in v1.2.
2) Give us a selection screen that works like 1) for the macros on the token so that we can also remove macros we don't want to copy over. I figure that most of the time, people will want to copy all of them, but being able to uncheck the macros you no longer use/need might be pretty nice. Right now if you have a bunch of macros you want to remove from a token it's actually a little annoying to "right-click>delete" them all. Using this would be easier.
In v1.3, I will integrate the "Macro Deletion Utility" from the Drop-In Resources forum. That will be easier than combining macro deletion with CIF's property removal macro.
3) Heck, giving us options in the macro to make any changes to all of the things that are being copied would be nice. Again, most will probably just want a straight copy, but it would be nice to be able to make quick changes right there.
Meh, sorry, I don't feel like doing that. I want the macro to have a dedicated, specialized function of deleting unwanted Properties (hidden or otherwise).
4) It's not currently copying the Vision type. The copy is always set to "normal." Can that be copied too?
Fixed in v1.2. Token Speeches, as well, were not covered by CIF's macro but have been added in.
5) How about an option to "Copy and Replace" the selected token so that we don't have to drag a "blank" image onto the screen and rename anything?
If you start by copying the source token, then you will still be stuck with any Properties it has sitting on it. In fact, that will be a problem if the "new" token is created from anything that already has Properties.

It occurs to me that I guess you could use the Lib token itself as a template for creating a new token, since it doesn't (as of this moment) have any Properties defined. Is that something I should work on implementing?
6) This doesn't copy over Portraits or Handouts. Can that be done by macro?
No, it can't, because there's no setPortrait() or setHandout() functions. The only way to copy these over is to use [wfunc]copyToken()[/wfunc] ... which, again, would preserve the old Properties that you want to get rid of. :(

I think Lights should be possible to copy to the new token, but I don't know enough about how Lights work (specifically, "types" of Lights) to implement this.

I put a warning into CIF's macro that warns the user that Lights, Portrait, and Handout will not be preserved.

--------

I also made two other improvements to CIF's macro, of my own volition:
  1. Made it more robust via JSON variables instead of lists, so that it can handle (e.g.) Property names with commas in them.
  2. Added an option to automatically delete the source token, put the new copied token in the same location, and give the new token the same name as the old one instead of adding "copy" to its name.
In v1.3, besides the Macro Deletion Utility, I intend to include the Macro Import/Export functions.
"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 work, Raoden.

In 1.3 it would be nice to see some output in the Chat window about when it's done, and maybe what it did.

It occurs to me that I guess you could use the Lib token itself as a template for creating a new token, since it doesn't (as of this moment) have any Properties defined. Is that something I should work on implementing?
Makes sense to me.

I think Lights should be possible to copy to the new token, but I don't know enough about how Lights work (specifically, "types" of Lights) to implement this.
Wouldn't you just use getLights and setLight?


Looking forward to 1.3. :)
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:Wouldn't you just use getLights and setLight?
The issue is what to put in the first parameter of Wiki: setLight(), which is supposed to be the light's "type." I don't see a way to read that information from the source token.
"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 »

Raoden wrote:The issue is what to put in the first parameter of Wiki: setLight(), which is supposed to be the light's "type." I don't see a way to read that information from the source token.
Maybe I'm missing something... under getLights it says:
If you want to specify the delimiter but still want to fetch all of the light source types then you can use the special value "*" for type.
But if you just want to return a string list of the light sources that the token has ON, you leave it blank:

Code: Select all

To get a string list  of all of the LightSource:light sources that the current token has on: [getLights()]
 
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 »

OK, I had some extra time today, so v1.3 is up. It includes macro Import/Export/Delete links.
Full Bleed wrote:In 1.3 it would be nice to see some output in the Chat window about when it's done, and maybe what it did.
This proved surprisingly difficult because of places where the code already utilized Wiki: abort(). Rather than wrestle with making umpteen little changes, I just put the output in a dialog instead of the Chat window. It was much easier; I hope it's still user-friendly.
It occurs to me that I guess you could use the Lib token itself as a template for creating a new token, since it doesn't (as of this moment) have any Properties defined. Is that something I should work on implementing?
Makes sense to me.
This will be a minor headache to implement, and a major headache if it includes having to deal with the possibility of the Lib token being on another map. For now, I think I'd rather just hold out for a functional removeProperty function.

Still on the To-Do list sometime:
  • Clean up code in general (especially DeleteMacro code, which was written when Rumble was much less experienced than he is now!)
  • Fix Lights, if possible
  • Allow re-ordering of JSON Array properties
"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 »

Slight change just made to v1.3: a Dialog was popping up unnecessarily due to improper nesting of roll options. Fixed now.
"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 »

Running into a problem when I have a default property value set as an evaluation like:

Code: Select all

StrMod:{floor((Strength-10)/2)}
When I use the copy feature, it puts the evaluated value into the property instead of keeping it NULL so that it continues to use the default property.

The was apparently happening with CiF's original code too, but I just now noticed it (because I was changing a number of things to auto-evaluate.)

The only way around it is to make sure that any evaluated property is NOT "copied" which is a little hard to do because you don't see the current value or defaults when selecting what to copy.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

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 »

Isn't that what Wiki: getRawProperty() was for? Just make sure you do your copies using that function...

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 »

Azhrei wrote:Isn't that what Wiki: getRawProperty() was for? Just make sure you do your copies using that function...
Unfortunately, there isn't a getAllRawPropertyNames to grab all the unevaluated props at once... I'll have to look at the code and see how I can use getRawProperty.


EDIT: Ok, I went with changing the section that builds the Dialog to uncheck copying any property that is currently using a default value because there is no reason to copy over a default value (should we even show them at all?) It italicizes and puts parenthesis around those values. Turns out setting the raw property was easy due to the way that section was set up.

New Dialog Building section:

Code: Select all

[h: '<!-- build dialog -->']
[h: fields = "[]" ]
[h: idx = 0]
[h, foreach( prop, allProps ), code:
	{		
		[h, if (getRawProperty(prop, src)==""), CODE:
			{
				[h: fields = json.append(fields, strformat("exclude%d|0|<html><i>(%s)</i></html>|CHECK", idx, encode(prop)))]
				[h: idx = idx+1]
			};
			{
				[h: fields = json.append(fields, strformat("exclude%d|1|<html>%s</html>|CHECK", idx, encode(prop)))]
				[h: idx = idx+1]
			}
		]
	}
]

New Property Write section:

Code: Select all

[h, foreach( prop, allProps ), code:
	{
		[h, if( json.contains( excludeList, prop ) ), code:
			{
			};
			{
				[h: setProperty( prop, getRawProperty( prop, src ), dest )]
			}
		]
	}
]
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

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 »

Raoden, any chance that you're going to update this tool with some of the code I posted above and using resetProperty?

I tried to run this in b69 and got the error:

Code: Select all

Function getPropertyNames requires no more than 1 parameters; 2 were provided.
I'm not sure why, the macro appears to be "trusted".


Also, I'm not sure moving to a json was the best thing when listing the props because now they show out of alphabetical order. Was there some reason why the switch to json was made?
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”