PF2CreatureParser Extension
This extension adds a new "Parse" tab to the NPC window. The intended usage is as follows:
- Create a new NPC record.
- Paste stat block into the string control on the "Parse" tab.
- Make any manual edits (see assumptions and caveats below).
- Click "PARSE" button.
At this point the NPC fields should be filled out. There is no harm in making more edits in the stat block control and then clicking PARSE again. In this case the entire block will be parsed again and all fields will be overwritten.
How much of the creature should I copy and paste?
The entire stat block starting with the line containing the name and level. Do not include the creature's flavor text. I would include an example picture, but I think I would be violating copyright if I did so?
CAVEATS AND ASSUMPTIONS
With their new stat block format, Paizo has not made it easy to parse these things. There are less keywords to look for compared to PF1 stat blocks, therefore there will be cases where simply copying and pasting a stat block from a PDF and blindly clicking PARSE will not yield the correct results. To make matters worse, I've already found instances of Paizo statblocks violating their own rules in The Bestiary (to be expected in a v1 publication). Luckily, clicking the PARSE button can be an iterative process and it's easy to adjust the stat block and push the button again, all fields will be overwritten in that case.
Here are some of the assumptions that the parser makes to be able do its job:
- The "Items" entry is a single line terminated with a line feed.
- HP, HP Abilities, Immunities, Weaknesses, and Resistances are all on the same line, terminated with a line feed.
- Immunities, Weaknesses, and Resistances are in that exact order. If they are out of order you will get unexpected results.
- Speed is on its own line, terminated with a line feed.
- Each Melee and Ranged strike entry is its own complete line, terminated with a line feed (this is really only important for the last strike entry, as we search for and split on 'Melee' and 'Ranged').
- All Melee lines come before any Ranged lines. All Ranged lines come before any Spells entries. All Spells entries come before any abilities.
- Each creature ability (interaction, automatic, reactive, offensive, and/or proactive) should be terminated with two line feeds, and the title of the ability and the ability description should be separated by a single line feed. NOTE: This is new behavior as of version 1.2 of this extension and release 14 of the ruleset, currently in the Test channel. If you are using a previous version of the ruleset, the old behavior is that each creature ability (name, traits and description) be on its own line terminated with a line feed.
If you have problems with a stat block, the first thing to do is to run through each of the items above to make sure you're not violating any of the assumptions. Helpful Hint: If you need to combine multiple lines into one, you can select all lines in the stat block control, and then press CTRL+J
Link to The Forge for this extension is in post #2, below.
Change History
8/4/2019 |
0.0 |
Initial Version. Parses everything prior to 'Speed'. |
8/4/2019 |
0.1 |
Fix issue with Weaknesses and Resistances. |
8/4/2019 |
0.5 |
Everything except Spells and Rituals should be working now. Fixed a few bugs in the top sections. |
8/7/2019 |
0.6 |
Everything on the Main tab should now be populating correctly. Fixed all reported bugs. Handle lock/unlock button correctly. |
8/13/2019 |
0.9 |
Most everything should be working now, with a few caveats. See Known Issues below. |
3/4/2020 |
1.0 |
V1. Fixed negative level issue. |
3/6/2020 |
1.1 |
Resolve most spell parsing issues. Add parse log functionality. |
3/28/2020 |
1.1.1 |
The string 'creature' in the first line of the stat block is now compared case insensitively. |
3/27/2020 |
1.2 |
Change parsing logic for interaction, reactive, automatic, offensive, and proactive abilities for ruleset version 14. Do not use with rulesets prior to release 14!!! |
3/28/2020 |
1.2.1 |
The string 'creature' in the first line of the stat block is now compared case insensitively. Do not use with rulesets prior to release 14!!! |
3/28/2020 |
1.2.2 |
Fix nil reference script error. Do not use with rulesets prior to release 14!!! |
4/19/2020 |
1.2.3 |
Compensate for change in GameSystem.actionTextToSymbols function return signature (now returns two values). Check for long versions of saving throw names and shorten them before parsing. |
7/10/2020 |
1.2.4 |
Handle a case where a string could be nil and writing to the parse log in this case would cause a script error. |
11/22/2020 |
1.2.5 |
Spells should now parse correctly when using extension in FGU. |
12/16/2021 |
1.2.6 |
4.1.12 compatibility release |
06/25/2022 |
1.2.7 |
Improvements to spells parsing. |
02/16/2023 |
1.2.8 |
Remove onInit function and announcement text.
Improve section parsing logic.
Add one bad char replacement.
Use getChildList and ipairs() instead of getChildren and pairs().
Additional parse log output.
Add focus spell tradition and type support for Magus, Oracle, Ranger, Summoner, and Witch. |
3/13/2023 |
1.3 |
Add the ability to parse JSON statblocks generated by https://monster.pf2.tools/. |
3/16/2023 |
1.3.1 |
- Add scrollbar to the text box on the Parse tab.
- UI cleanup on the Parse tab.
- Wrap some of the JSON values with tonumber() where they could be either string or number type.
- Fix logic in buildSpellBlock that was causing a script error when the NPC being parsed did not have any spell blocks.
- Parsed NPCs will now contain the Recall Knowledge DC for the NPCs level on the Other tab. |
5/21/2023 |
1.3.2 |
Fixed a data bug that would cause Acrobatics to show up twice in the skills list. |
7/22/2023 |
1.3.3 |
More logic-proofing for nil values. |
3/11/2024 |
1.4 |
Compatibility release for FG v4.5.0 |
KNOWN ISSUES
- If you create a new NPC record, go directly to the Parse tab, paste the statblock and hit PARSE, you will end up with spell classes and levels, but no spells on the Actions tab. I'm still trying to figure out exactly why, and how to fix this. As a workaround, it seems like you need to make the Actions tab visible at least once before parsing.
- Formulas are not being parsed yet.
- I'm not done with Rituals yet. It will create the spell class, but no levels or spells.