d20 StatBlock Importer: Pathfinder/DnD3/3.5

Show off your RPG maps, campaigns, and tokens. Share your gaming experiences and stories under General Discussion and save this forum for things you've created that may help others run their own games. Use the subforums when appropriate.

Moderators: dorpond, trevor, Azhrei, Gamerdude

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Zandel wrote:How do you actually view the macros that are included with the Library token? I see how to run them, but how do I view the code?

Right-click on the macro button and select "Edit". That should bring up a dialog with macro settings. You can copy all the code, paste it in your favourite text-editor, and copy/paste it back in. Or, edit directly in the dialog, although it's pretty basic and not exactly designed as a proper text-editor.

Hope that helps.
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

Zandel
Giant
Posts: 133
Joined: Thu May 13, 2010 1:52 pm

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Zandel »

I don't have a macro button, its a library token I dragged onto the map, if I go to import, I don't see the macros that are part of the library token

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Zandel wrote:I don't have a macro button, its a library token I dragged onto the map, if I go to import, I don't see the macros that are part of the library token

If you select the library token in MapTool, you should see all the macros (as buttons) in the "Selected" pane. If that's not visible, try going to the 'Window' menu and selecting 'Selected' or 'Restore Layout'?
I also recommend dragging the macro in the "0. Campaign Macros" category to the campaign macros pane, for future use.
And don't forget to click on 'onCampaignLoad' the first time you drag the Lib:Token onto the map, to define the functions.

... unless something drastic has changed in recent builds?
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

Zandel
Giant
Posts: 133
Joined: Thu May 13, 2010 1:52 pm

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Zandel »

Got it working Thanks!!

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Updated the Lib:Token in the original post.
It now contains a UI to assign fields of parsed data to Token Properties. The target properties can be chosen from a list of properties available on a selected token, or entered manually. The mapping can be saved, or temporarily ignored.
This property map is used by the basic processing macro on the Lib:Token, but can safely be ignored if a custom interpreter is written for a particular framework.
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

User avatar
Full Bleed
Demigod
Posts: 4519
Joined: Sun Feb 25, 2007 11:53 am
Location: MD
Contact:

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Full Bleed »

biodude wrote:Updated the Lib:Token in the original post.
It now contains a UI to assign fields of parsed data to Token Properties. The target properties can be chosen from a list of properties available on a selected token, or entered manually. The mapping can be saved, or temporarily ignored.
This property map is used by the basic processing macro on the Lib:Token, but can safely be ignored if a custom interpreter is written for a particular framework.


I was trying this out and go this error in b70:

Undefined function: outputTo



I think the "Preview & Map" feature is a really nice feature.

But I have some suggestions for it. How about letting us select the "Token Type" and then use a drop-down list in each field with all the properties that are available in that token type (getAllPropertyNames)? Have it default to not assigning the value to any property. This would make it a lot easier to set it up.

I happen to use a lot of string property lists (for feats, skills, classes, weapons, etc). Any chance it could recognize that and allow us to assign something specifically to a value within a list? If I can't do it from a nice UI I'll have to go into your code and try and figure out how to. ;)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Full Bleed wrote:...

I was trying this out and go this error in b70:

Undefined function: outputTo

Yeah, it's just there for output. The errors are not generated in earlier builds, but it's the generic outputTo function that's been around for a while. I can either add it in, or drop the output messages to chat.

Full Bleed wrote:I think the "Preview & Map" feature is a really nice feature.

But I have some suggestions for it. How about letting us select the "Token Type" and then use a drop-down list in each field with all the properties that are available in that token type (getAllPropertyNames)? Have it default to not assigning the value to any property. This would make it a lot easier to set it up.

I thought about using the "Token / Property Type", but I wanted to get something together quickly first.
Nevertheless, if you assign a token to a particular 'Type' (set of properties from the campaign properties), all the properties are defined on the token anyway. The way it is now, you also have access to ALL properties defined on a token, whether they are part of a "Token Type" or not. On the other hand, you might not want to see these in the drop-down list. I could see both ways being useful, but I won't change it until I hear a good reason for it, and I find the time ;-)

With regards to defaults, which is easier / most useful:
1. Have it automatically try to assign a field to property (of the same name)
2. Don't assign the value to any property until explicitly told to do so.
I thought #1 would make set-up faster, since it means having to assign fewer things: you only have to worry about the fields that have different names than what the parser uses. Currently, if a matching property is not found, it imposes the field name as the default, but I sense that is undesired.
What do people think about a compromise: The mapper can try to find a matching property name as an initial default, but if none is found, the default is to not assign the value at all?

Full Bleed wrote:I happen to use a lot of string property lists (for feats, skills, classes, weapons, etc). Any chance it could recognize that and allow us to assign something specifically to a value within a list? If I can't do it from a nice UI I'll have to go into your code and try and figure out how to. ;)

I can't see a simple way of doing that dynamically, which is why I set-up the Lib so that the "Processing" is separate from the parsing. If you want to plug the data into your custom framework, you will eventually have to get into the code and write your own interpreter.
The basic processor is just there for simple assignment of values. I always intended for others to write a framework-specific processing macro ("Framework Interpreter") to convert the values generated by the parser into whatever data format is used by a particular framework. Unless the basic one gives you everything you need, in which case: YAY :mrgreen: !

Because there are so many different ways of structuring the data, I figured it would be easier to write a framework-specific interpreter than to try to anticipate all possible data structures. The interpreter doesn't have to be super-fancy: it would be a series of Wiki: json.get() statements to retrieve the values found by the parser (use it as you would Wiki: getStrProp()), and then whatever processing is needed to get the data into the framework: you would also have the advantage of being able to use any UDFs defined for building data structures specific to your framework, which I could never anticipate.
Note that the mapping UI is also a convenient reference for writing such an interpreter: use it to see what fields are generated, and what values they contain, so you can use them the way you want.

The goal of this tool is to handle the parsing, and make it easier to "plug in" to your framework (so you don't have to write your own parser, just the interpreter). I welcome any suggestions to making the output more useful in this regard, but I'm afraid I can't make it fit all the possible frameworks on my own: that is up to you guys ;). Feel free to post interpreters for popular frameworks if you have them (The lib includes one for my homebrew framework, which is not popular, but at least it is an example of a 'custom' interpreter).

Thanks for the feedback, keep it coming!
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

Zandari
Cave Troll
Posts: 63
Joined: Mon Feb 11, 2008 8:52 pm

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Zandari »

Admittedly, I am not a programmer, but what the heck do I do with this thing to make something happen?

I pop the lib.statblock.blah.blah token on my map and make it visible
I drag another blank token over next to it (an Ankheg, actually)
I cut the text of the statblock from the pfsrd
I click on selected, and can now see several macros:
onCampaignLoad (I clicked that first, as directed in another post)
Token:select target focus (This appears to have no effect)
styles.css (another button that does nothing)
Import StatBlock text (does nothing)
StatBlock:Import (hey! something happens) - at this point, a window pops up asking me to provide "Value For targetTokens" the default is 0, I don't know what this means, so I say OK. the same window pops up again, and this time, I also say OK

Now I get a new window that asks me to "Paste StatBlock text into the box below and click a button" I do so and click Apply> - nothing appears to happen

I try the process again and click "Preview and Map" instead - nothing appears to happen

Figuring maybe I need to give it the name of the blank token I want it to apply to, I do the whole process again. This time, when it asks me for "Value for TargetTokens" I type in "Ankheg", which is the name of the blank token on the map. I still have to do it twice, which is confusing, but this time, when I get the "Paste StatBlock" windo, there is a picture of the library token at the bottom, with the name Ankheg next to it. I begin to get excited here, figuring I may be on to something.

Sadly, after I click Apply>, nothing appears to have changed. The Ankheg token does not have any neat new properties, nothing.

Would it be possible to give a bit of instruction on exactly how and what this macro accomplishes? Is it supposed to give a token a set of properties and then give each of those properties a value based on the statblock? Because that is what I expected it to do, and that would be awesome as a way to quickly give properties to tokens. But, I can't get it to do anything at all.

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Zandari wrote:Admittedly, I am not a programmer, but what the heck do I do with this thing to make something happen?
...
Would it be possible to give a bit of instruction on exactly how and what this macro accomplishes?

I'm so sorry for your frustration: I was just thinking I should include some more detailed instructions, which I will.
[EDIT: instructions now included in the top post, and the new version of the Lib:token includes a "Help" macro to provide the same info.]
The "Import StatBlock" macro (in the the "0. Campaign Properties" group) is really the only macro you need to use, but you have to select the tokens to which you want to apply the statblock values. The trick is being able to select the target tokens, and activate this single macro at the same time.

For the moment, here are 2 methods:
1. impersonate the Lib:Token (Lib:StatBlock.blah.blah). The macros should now appear in the 'Impersonated' window (if this window is not visible, activate it from the 'Window' menu).
- Select the target token(s) you want to apply the statblocks to (note the macros from the lib token will still be visible in the 'Impersonated' window as long as the token is impersonated), then click on the macro in the "0. Campaign Properties" group ("Import StatBlock"). That should bring up the input dialog and all the rest.

2. Select the lib token, and drag the "Import StatBlock" macro (from the the "0. Campaign Properties" group) to your Campaign macros, and activate it from there.

Zandari wrote:Is it supposed to give a token a set of properties and then give each of those properties a value based on the statblock? Because that is what I expected it to do, and that would be awesome as a way to quickly give properties to tokens. But, I can't get it to do anything at all.

That's exactly what it is supposed to do. And I agree, it is pretty awesome, which is why I made it. But, as you can see, it can still be better. Thanks for sticking around and posting your questions. Suggestions are always appreciated.

I hope that helps, and I apologize for the confusion.
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

How do I customize this for my favourite framework?
This section assumes you are familiar with working with macros in MapTool (writing, editing, etc.). For help with that, please refer to the excellent RPTools Documentation wiki.

The goal of this tool is handle all the parsing for you, producing data in a convenient format readily accessible by MapTool. Given the infinite possible data structures any given framework could conceivably use to organize this data, the goal here is not to try to guess how you want the data structured on the token, but rather to provide it in a format that makes it relatively easy to convert it into the format for your framework.

This tool does include a convenient "Preview & Map" function, which saves a map of field names to token properties. This 'map' is used by the basic (default) processing macro to assign the parsed values to token properties of your choice (or none, if you so desire). While this may satisfy your basic desires to get values onto a token, you may find your framework requires the data to be structured differently, which the map cannot handle. If this is the case, you need what I call a 'Framework Interpreter' to convert the parsed data into formats appropriate for your framework, and assign destination properties to the new values.

Writing a Framework Interpreter
A 'Framework Interpreter' is a custom processing macro that converts the parsed values to desired data structures and assigns the new values to destination properties. There are two examples included in the Lib:token, in the group "3. Process Parsed Values": feel free to use either of these as a template or starting point for your own.

Arguments received: a json object of parsed values. You can easily see the names and the type of data in each via the "Preview & Map" command (just ignore the mapping to token properties part).
Value returned: a json object of destination token properties (as fields / keys) and associated values. The Main macro will loop through this json object and assign the values to properties on each of the selected tokens, according to the import options entered (or saved).
Optional data: you can also access the import options, should you desire (though they all act independently of the interpreter), by retrieving the Lib Property 'JAW_STATBLOCK_PREFS': e.g.

Code: Select all

[ importOptions = getLibProperty( 'JAW_STATBLOCK_PREFS' )]
The options are stored as a String Property List (StrProp).

You may choose to assign all the property values yourself, although you will need to access the list of selected target tokens, which is not automatically accessible. In this case, simply return an empty json object (or empty string). The reason the processing macro does not assign values directly is to make the process more efficient: the processor / interpreter only needs to convert the data to appropriate formats once, and then the values can be applied to all selected tokens, rather than converting the data and applying to each token individually.

The bulk of the processing includes retrieving parsed values:

Code: Select all

[ tempVar = json.get( new.values , 'Skills.totals' ) ]
converting them to a format appropriate to your framework:

Code: Select all

[ SkillsNew = format.skills( tempVar ) ]
and assigning them to destination token properties:

Code: Select all

[ tokenProps = json.set( tokenProps , 'Skills' , SkillsNew ) ]

Note that you are free to use any user-defined functions in your framework to create or format appropriate data structures. So long as you use this tool with your framework, these functions should be accessible.

Ok, I have a custom interpreter, what do I do with it?
Open the macro 'StatBlock: process' and replace the contents with the custom interpreter for your framework. You may want to make a copy of the macro first (and re-name it something else), in case you ever want to use the property map again.
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

Raileth
Cave Troll
Posts: 28
Joined: Fri Oct 12, 2012 5:09 pm
Location: Camberley, UK

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Raileth »

Hi,

I've been playing with RPTools for a couple of weeks now, slowly putting together my own framework for pathfinder. I realise that there are several out there but none that seemed to meet my needs. Anyway as part of my searching around I came accross this tool, which is outstanding. I have created several custom properties and this tool allows me as a GM to quickly load in creatures etc, and then manage them with the macro's i've written:- Applying damage, calculating states, and healing.

As part of that I have expanded the tool to be able to accept a heroforge statblock (created a heroforge parser- well copied the pathfinder one and adjusted it a bit), while most of it works fine as its pretty standard Heroforge has got a little bit of extra information that I'd like to add in. The statblock is broken down Like This:-

[spoiler=]Bloody Skeletal Champion CR 10
XP 9600
Human Fighter 6
NE Medium Undead
Init +7; Senses Darkvision; Perception +10
--------------------
Defense
--------------------
AC 21, touch 13, flat-footed 18 (+6 armor, +3 Dex, +2 natural)
hp 73 (6d10+2d8+24)
Fort +7, Ref +5, Will +4 (+2 vs. fear); +4 vs. channel
Defensive Abilities Bravery +2, Channel Resistance +4; DR 5/bludgeoning; Immune cold, Undead Traits
--------------------
Offense
--------------------
Speed 30 ft.
Melee +1 Greatsword +14/+9 (2d6+10/19-20/x2) and
Claw x2 (Skeletal Champion) +6 x2 (1d4+2/x2)
Ranged +1 Composite longbow (Str +4) +12/+7 (1d8+7/x3)
Special Attacks Weapon Training: Blades, Heavy
--------------------
Statistics
--------------------
Str 18, Dex 17, Con -, Int 10, Wis 8, Cha 14
Base Atk +7; CMB +11; CMD 24
Feats Deadly Aim -2/+4, Improved Initiative, Point Blank Shot, Power Attack -2/+4, Toughness +8, Vital Strike, Weapon Focus (Greatsword), Weapon Focus (Longbow), Weapon Specialization (Greatsword), Weapon Specialization (Longbow)
Skills Acrobatics +0, Climb +6, Escape Artist +0, Fly +0, Intimidate +13, Perception +10, Ride +4, Stealth +8, Survival +3, Swim +5
Languages Common
Combat Gear +1 Composite longbow (Str +4), +1 Greatsword, Breastplate;
--------------------
Special Abilities
--------------------
Bravery +2 (Ex) +2 Will save vs. Fear
Channel Resistance +4 +4 bonus to save vs. Channel Energy.
Damage Reduction (5/bludgeoning) You have Damage Reduction against all except Bludgeoning attacks.
Darkvision (60 feet) You can see in the dark (black and white vision only).
Deadly Aim -2/+4 Trade a penalty to ranged attacks for a bonus to ranged damage.
Immunity to Cold You are immune to cold damage.
Point Blank Shot +1 to attack and damage rolls with ranged weapons at up to 30 feet.
Power Attack -2/+4 You can subtract from your attack roll to add to your damage.
Undead Traits Undead are immune to death effects, disease, mind-affecting effects (charms, compulsions, morale effects, phantasms, and patterns), paralysis, poison, sleep, stun, and any effect that requires a Fortitude save (unless the effect also works on objects
Vital Strike Standard action: x2 weapon damage dice.
Weapon Training: Blades, Heavy +1 (Ex) +1 Attack, Damage, CMB, CMD with Heavy Blades

Hero Lab® and the Hero Lab logo are Registered Trademarks of LWD Technology, Inc. Free download at http://www.wolflair.com
Pathfinder® and associated marks and logos are trademarks of Paizo Publishing, LLC®, and are used under license.[/spoiler]

What i wanted to do was put everyting after the '--------------------Special Abilities--------------------' but before where it reads Hero Lab® into one property, but i have been unable to separate it out.. Are you able to help / point me in the right direction.

Thanks very much

Grant
Raileth

User avatar
biodude
Dragon
Posts: 444
Joined: Sun Jun 15, 2008 2:40 pm
Location: Montréal, QC

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by biodude »

Hi!

I'm so glad you like the tool. However, I should point out that it is OLD - I haven't looked at this in over 2 years - as you can probably tell from the date of that last post.

I've since hit the home stretch of my PhD, while starting a full-time job, and just haven't had time to keep up with RPTools :(

From what I remember, the parser was basically a lot of regex (Regular Expressions) to pull out standard properties. I think I was experimenting with "auto-detecting" the type of statblock to call the appropriate macro to parse it, and then a different "Framework Interpreter" to turn the parsed data into token properties for a custom framework.

In your custom parser for heroforge, you might have to add a line that creates a property for your "Special Abilities". You will either have to design a regular expression that captures just what you want, or do it in several stages: extract everything after "Special Abilities", and then remove everything after a blank line, for example.

If I Recall Correctly, you should be able to add that result as a property to the final JSON object in that parser macro, and the default Framework Interpreter macro will automatically assign all that to a property.

I'm sorry I can't help more at the moment, but I hope that helps. Maybe one of the other vets on the forum can help with any specific questions you have. If you're really frustrated, send me a private message and I'll see what I can do.

Cheers :D
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]

Raileth
Cave Troll
Posts: 28
Joined: Fri Oct 12, 2012 5:09 pm
Location: Camberley, UK

Re: d20 StatBlock Importer: Pathfinder/DnD3/3.5

Post by Raileth »

No worries, thanks for the prompt reply, I guessed it was pretty old stuff but it seems to cover most of what I needed, off to learn all about regex then :)

Grant
Raileth

Post Reply

Return to “User Creations”