PF statblock importer
Moderators: dorpond, trevor, Azhrei, giliath, Gamerdude, jay, Mr.Ice, lmarkus001
Forum rules
Discussion regarding lmarkus001's framework only. Other posts deleted without notice!
Discussion regarding lmarkus001's framework only. Other posts deleted without notice!
Re: PF statblock importer
Nope, we want the parens because they create a regex group that can be extracted from the string as a match.
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
I ran into a problem with the above.Full Bleed wrote:I couldn't get any of the suggestions made to work, so after some gnashing of teeth, I figured out something that works for me:
Code: Select all
[H: id = strfind(statblock, "hp ([0-9]+).(\\((.+)\\))?.?Fort")] [H, IF(0<getFindCount(id)),CODE: { [HP=getGroup(id, 1, 1)] [MaxHP=HP] [HD=getGroup(id, 1, 2)] } ]
It works for most situations because they look like this:
But some look like this:hp 92 (8d10+48)
Fort +12, Ref +5, Will +10
So, how do I get it to stop at the semi-colon OR "Fort"?hp 92 (8d10+48); regeneration 5 (fire or acid)
Fort +12, Ref +5, Will +10
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: PF statblock importer
Remove the trailing .?Fort and that should do it.Full Bleed wrote:So, how do I get it to stop at the semi-colon OR "Fort"?
Re: PF statblock importer
Here's the regex I've been using to extract die rolls with pluses, inside parentheses:Full Bleed wrote:I've been customizing the statblock2token macro for my framework and I was wondering if someone knew a way to grab the HP values inside the parenthesis using strfind?
That is, if the statblock reads:
hp 80 (7d10+42)
I'd like to be able to grab the "7d10+42" value.
That way I can quickly randomize the hitpoint values of monsters I drop into the game instead of using the default values (which are usually pretty weak.)
\\([-0-9d\\+]+\\)
I haven't tested in thoroughly, but it should grab anything that looks like die rolls (numbers, the letter 'd', +/-) in a continuous sequence, with a bracket on either end. If you don't want the brackets, but want to capture everything inside, a lookaround might work instead:
(?<=\\()[-0-9d\\+]+(?=\\))
"The trouble with communicating is believing you have achieved it"
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]
[ d20 StatBlock Importer ] [ Batch Edit Macros ] [ Canned Speech UI ] [ Lib: Math ]
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
Nope. It doesn't stop at the semi colon... in fact it continue to the end of the statblock making for one very large property value.Azhrei wrote:Remove the trailing .?Fort and that should do it.Full Bleed wrote:So, how do I get it to stop at the semi-colon OR "Fort"?
Biodude, I'm going to need more specific info on where and how to plug in those examples using the code I posted above... what I've tried doesn't seem to work.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: PF statblock importer
Huh?Full Bleed wrote:Nope. It doesn't stop at the semi colon... in fact it continue to the end of the statblock making for one very large property value.
Ohhhh, I see. The regex is being greedy about what is inside the parens so it grabs everything up to the last close paren! Try this instead:
hp ([0-9]+).(\\((.+?)\\))?
Notice that the same "Fort" string is removed, but there's also a "?" after the ".+" -- that makes for the shortest possible string instead of the (default) longest possible string.
Now the regex will break if the parens contains nested parens, but there's no easy way to handle nested parens within RE's so hopefully that doesn't happen.
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
That did the trick! Thanks.Azhrei wrote:Try this instead:
hp ([0-9]+).(\\((.+?)\\))?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
Ok, next problem.
I'm looking to have the parser set the level of specific classes.
So, I'm currently using this to grab the first number after a particular class name:
The problem is that Clerics (and maybe some other classes) say things like: "cleric of iomedae"
So what I need is for the parser to find the class name and then grab the next number irrespective of what text lies between the text and the number.
I'm looking to have the parser set the level of specific classes.
So, I'm currently using this to grab the first number after a particular class name:
Code: Select all
[H: id = strfind(statblock, "warrior ([0-9]+)")]
So what I need is for the parser to find the class name and then grab the next number irrespective of what text lies between the text and the number.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: PF statblock importer
Something like:
ought to do it. It's just classname(some characters)(capture group forthe number). The match is not greedy, to avoid running past the next number (or that's the idea). So that would get
cleric of iomedae 10
as well as
cleric 5
If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.
Code: Select all
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]
cleric of iomedae 10
as well as
cleric 5
If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
Thanks. Works great.Rumble wrote:Something like:
Code: Select all
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]
And thanks for the links. Beats the heck out of trial and error in MT!If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: PF statblock importer
No prob. What I usually do is create it in RegExr, and then put it in the Java tester to see what works. I then copy the pattern from the Java tester page, since that formats it for Java's regex engine, which is what MapTool uses.Full Bleed wrote:Thanks. Works great.Rumble wrote:Something like:
Code: Select all
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]
And thanks for the links. Beats the heck out of trial and error in MT!If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.
Re: PF statblock importer
Be careful as there are some multi-class NPC's and I am not certain this grabs the true class level in that case.
Re: PF statblock importer
That may be. If it was warrior 5/peasant 2/cleric 4 or whatever, it wouldn't - but you could extend it to capture those as well and sum them up.neofax wrote:Be careful as there are some multi-class NPC's and I am not certain this grabs the true class level in that case.
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: PF statblock importer
That's exactly what I do. I loop through a list of all classes and assign levels accordingly. I have a udf that pulls the total level or the level of a particular class.Rumble wrote:That may be. If it was warrior 5/peasant 2/cleric 4 or whatever, it wouldn't - but you could extend it to capture those as well and sum them up.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: PF statblock importer
Thanks Rumble that second site you mention stopped the contusions from appearing on my forehead everytime I bang my head on the desk. For the life of me I could not figure out the rules for RegEx. I could monkey see monkey do whatever anyone else had done and get returns when they matched but If I needed something new I was out of luck. All of the tutorials I read didn't quite line up with the rules that MT was using. This site led me to my fisrt success so I'm real happy. So again thanks.Rumble wrote:Something like:
ought to do it. It's just classname(some characters)(capture group forthe number). The match is not greedy, to avoid running past the next number (or that's the idea). So that would getCode: Select all
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]
cleric of iomedae 10
as well as
cleric 5
If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."