Page 5 of 7

Re: PF statblock importer

Posted: Thu Jul 15, 2010 11:29 pm
by harchunk
Are you copying the stat blocks directly from the PFSRD?

Re: PF statblock importer

Posted: Thu Jul 15, 2010 11:38 pm
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

Re: PF statblock importer

Posted: Sun Apr 24, 2011 4:44 pm
by Elorebaen
I am using ver1.6 and it has been a HUGE timesaver. Thank you!!!!

Re: PF statblock importer

Posted: Sun Apr 24, 2011 9:14 pm
by Azhrei
There's a 1.8 floating around; I think it's included in Neofax's "Pathfinder Framework" configuration.

Re: PF statblock importer

Posted: Sun Apr 24, 2011 9:24 pm
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!

Re: PF statblock importer

Posted: Mon Jul 04, 2011 8:16 pm
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.

Re: PF statblock importer

Posted: Mon Jul 04, 2011 9:00 pm
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. ;)

Re: PF statblock importer

Posted: Mon Jul 04, 2011 9:15 pm
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).

Re: PF statblock importer

Posted: Tue Jul 05, 2011 5:26 pm
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.

Re: PF statblock importer

Posted: Tue Sep 25, 2012 3:06 pm
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?

Re: PF statblock importer

Posted: Tue Sep 25, 2012 3:50 pm
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.

Re: PF statblock importer

Posted: Tue Sep 25, 2012 11:43 pm
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...

Re: PF statblock importer

Posted: Wed Sep 26, 2012 11:51 am
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.

Re: PF statblock importer

Posted: Wed Sep 26, 2012 10:43 pm
by Full Bleed
CoveredInFish wrote:But this is the way to replace weird characters.
Nice work.

As always... thanks! :)

Re: PF statblock importer

Posted: Wed Sep 26, 2012 11:36 pm
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.