Features & notes:
- includes a 'Help' macro, which produces a frame with reference instructions and macro links to try it out.
- "Preview & Map" UI (not shown in demo) to display parsed values before applying them, and also map fields to destination Properties on the tokens. These settings are used by the 'Basic' Processing macro included in the Lib: token, but can easily be changed or ignored by a custom framework interpreter.
- Until a 'property map' is saved, this will try to match property names on the token with field names produced by the parser. If no match is found, the field will not be applied to any property. Once a 'map' is saved, fields will be assigned to the token property specified in the map (or none).
- If a Name is parsed, it is used to set the GM Name (not the Token Name).
- The original text input is appended to the end of the GM Notes (for future reference).
- Modular structure to facilitate adding support for additional sources, or customizing the processing for a particular framework (see below).
It currently has parsers for the following sources:
- Pathfinder (http://www.d20pfsrd.com bestiary)
- DnD 3e pdf*
- DnD 3.5 pdf*
* The pdf parsers are a bit buggy, and pdf text encoding and inconsistent formats sometimes cause trouble with a few of the properties, however, all the basic stats (Ability Scores, saves, etc.) are pretty reliable.
I don't have one for Pathfinder PDFs yet, mostly because I haven't found an example to test (I only have the core material, none of the accessories written for the PF system). It would be good to know if the Pathfinder parser can handle pdf sources as well as the online ones.
There is also a small section that can try to "Auto-detect" the source, based on the string contents (certain labels specific to the different StatBlock formats), but a specific source can always be selected, just to be sure.
Feel free to try it out, and share anything you think would improve it.
How to Install & Use
1. Download the Lib:token linked above, and drag the .rptok file onto a map in your campaign.
2. select the Lib:token, and click on the "onCampaignLoad" macro to define the functions. You only need to do this the first time you drag the Lib:token into your campaign file (it runs automatically when you open a campaign file with the lib:token in it).
3. Drag the macro named "Import StatBlock text", in the "Campaign Macros" group, over to your campaign macros (or token macros or wherever you can access it while selecting multiple tokens).
3.1 Alternatively, impersonate the Lib:Token so you can access the "Import StatBlock text" macro while selecting other tokens.
4. To use this tool, select the tokens to which you want to apply statBlock values, and then activate the "Import StatBlock text" macro (from wherever you dragged it to, or directly from the Lib:Token as above). This generates the input dialog where you can paste in your Stat Block text, choose the source, preview the parsed values & assign them to token properties, or apply the values directly.
The "Import StatBlock" macro (in the the "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.
How do I customize this for my favourite framework?
see this post for more details.
Figure 1. Empty token and interface ready for input.
Figure 2. Text Input, and available options for the source. The Auto-detect should work fine for this text from pfsrd.com
Figure 3. Values applied. Note the token has automatically changed size, based on the value pulled from the statBlock.
Concept & Structure:
I divided the entire import process into 3 main sections / macros:
- Main Interface & coordination:Generates interface, hands data off to other macros and sends the results somewhere appropriate.
- Parsing: pulls stats out of the text and assembles a json object of the values with sensible labels (keys), using a separate macro for each possible source.
- Processing ("Framework Interpreter") : takes the json object produced in the previous step and converts it to an object with property names and values. This is the part that is specific to a given framework. The Lib:token for download includes a basic version, and an example for my homebrew framework, if you want to see something fancier.
This way, I figure it makes it easier to add more parsers for different sources, and customize the processing for your preferred framework, while keeping the code neatly organized.