PF statblock importer

Discussion concerning lmarkus' campaign framework for D&D3.x and Pathfinder.

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

Forum rules
Discussion regarding lmarkus001's framework only. Other posts deleted without notice! :)
User avatar
harchunk
Giant
Posts: 116
Joined: Sat Mar 22, 2008 7:12 pm

Re: PF statblock importer

Post by harchunk »

Are you copying the stat blocks directly from the PFSRD?

User avatar
harchunk
Giant
Posts: 116
Joined: Sat Mar 22, 2008 7:12 pm

Re: PF statblock importer

Post by harchunk »

harchunk wrote:Are you copying the stat blocks directly from the PFSRD?


I will answer my own question...........yes
wow!!! pretty sweet I copied a gobo and it saved me about 20 mins of work.

YOU DA' MAN

Elorebaen
Dragon
Posts: 364
Joined: Sat Dec 22, 2007 5:37 pm

Re: PF statblock importer

Post by Elorebaen »

I am using ver1.6 and it has been a HUGE timesaver. Thank you!!!!

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

Re: PF statblock importer

Post by Azhrei »

There's a 1.8 floating around; I think it's included in Neofax's "Pathfinder Framework" configuration.

Elorebaen
Dragon
Posts: 364
Joined: Sat Dec 22, 2007 5:37 pm

Re: PF statblock importer

Post by Elorebaen »

Azhrei wrote:There's a 1.8 floating around; I think it's included in Neofax's "Pathfinder Framework" configuration.


Thanks for the head's up!

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: PF statblock importer

Post by neofax »

Can someone help me with a regular expression that will parse out multiple damage reductions and energy resistances in a statblock? Here is an example:

Code: Select all

Defensive Abilities Bravery +0, Channel Resistance +4, Ferocity; DR 10/good, 5/slashing; Immune Undead Traits; Resist cold 15, fire 15; SR 16


What I need is a way to pull 10, good then 5, slashing and 15, cold and 15, fire.

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

Re: PF statblock importer

Post by Azhrei »

What does full resistance via DR look like? Would it be -/slashing, for example?

In these examples I'm using a double-backslash as I expect these are being put into one of the MT regex functions and they require the backslash be protected by another backslash.

Try this regex to extract the DR (the first four characters turn off case-sensitivity; you may or may not want that depending on your incoming data):

Code: Select all

(?i)\\bDR (\\d+)/(\\S+)(,(\\d+)/(\\S+))*\\b

And this one to extract the resistances:

Code: Select all

(?i)\\bResist (\\w+) (\\d+)(,(\\w+) (\\d+))*\\b

There are some assumptions made in the above based on the sample you posted, so if you find that they do not work for a given input just post the sample data and we can update the RE.

I haven't tested either of these, but I think they're pretty darn close. ;)

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: PF statblock importer

Post by neofax »

Azhrei wrote:What does full resistance via DR look like? Would it be -/slashing, for example?

In these examples I'm using a double-backslash as I expect these are being put into one of the MT regex functions and they require the backslash be protected by another backslash.

Try this regex to extract the DR (the first four characters turn off case-sensitivity; you may or may not want that depending on your incoming data):

Code: Select all

(?i)\\bDR (\\d+)/(\\S+)(,(\\d+)/(\\S+))*\\b

And this one to extract the resistances:

Code: Select all

(?i)\\bResist (\\w+) (\\d+)(,(\\w+) (\\d+))*\\b

There are some assumptions made in the above based on the sample you posted, so if you find that they do not work for a given input just post the sample data and we can update the RE.

I haven't tested either of these, but I think they're pretty darn close. ;)


Thanks Azhrei! They both work for grabbing 2 resistances or reductions, but if there are more say 5? Would I need to do a FOREACH? Also, yes the all normally is a -/damage reduction(however it could be an em-dash).

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

Re: PF statblock importer

Post by Azhrei »

neofax wrote:Thanks Azhrei! They both work for grabbing 2 resistances or reductions, but if there are more say 5? Would I need to do a FOREACH? Also, yes the all normally is a -/damage reduction(however it could be an em-dash).

They will work with any number with a minimum of one. Yes, you will need a loop to process additional ones. The info for the regex functions on the wiki should give some information although IIRC they were pretty sparse. I think you need to loop through the "match groups" and then within each match group there will be a number and a string.

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

Re: PF statblock importer

Post by Full Bleed »

I'm using a modified version of this importer but I've run into a problem.

Pathfinder statblocks use a "–" for a "-" ... and I've run into a problem where MT doesn't see the two being the same. So, for example, if a monster has a "–1 init", when I try to roll initiative for them I get "12–1" instead of "11".

I tried doing a simple replace (– with -) in the statblock string but MT throws an error so I must have the syntax wrong.

So, assuming my statblock string is called statBlock, how would I make the above replacement?
Last edited by Full Bleed on Tue Sep 25, 2012 11:41 pm, edited 1 time in total.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

neofax
Great Wyrm
Posts: 1694
Joined: Tue May 26, 2009 8:51 pm
Location: Philadelphia, PA
Contact:

Re: PF statblock importer

Post by neofax »

I handle this by copying all of the stablocks to notepad++ in one text file and then strip them from all of the special characters.
Image
Time-Zone information UTC -5

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

Re: PF statblock importer

Post by Full Bleed »

neofax wrote:I handle this by copying all of the stablocks to notepad++ in one text file and then strip them from all of the special characters.


I would like to avoid doing that. I'm hoping that there is a way to use replace() in MT...
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: PF statblock importer

Post by CoveredInFish »

Full Bleed wrote:I'm hoping that there is a way to use replace() in MT...

Maybe this will help you? I dont know a thing about the statblock importer, so I cant guide you on hacking it. But this is the way to replace weird characters.

Code: Select all

<!--
encoded dash sign = %E2%80%93
minus sign doesnt get encoded
-->
[h: input("sampleString")]
ENCODED = [r: sampleString = encode(sampleString)]<br>
REPLACED = [r: sampleString = replace(sampleString, "%E2%80%93", "-")]<br>
DECODED = [r: decode(sampleString)]

Having the dash sign in the macro code leads to errors here, so I used an input() in this example. It worked fine with this test-string "A – B - 1" copy-pasted into the input.

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

Re: PF statblock importer

Post by Full Bleed »

CoveredInFish wrote:But this is the way to replace weird characters.


Nice work.

As always... thanks! :)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
Deity
Posts: 8578
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: PF statblock importer

Post by aliasmask »

I was thinking any non-ascii characters are not submitted correctly through the form submit. But, I think you can add something to the java line to enable unicode characters. Otherwise, all those special characters are just passed as squares, I think.

Post Reply

Return to “[D&D3.5 + Pathfinder] Campaign Macros”