RPTools.net

Discussion and Support

Skip to content

It is currently Fri Feb 23, 2018 7:50 am 




Forum rules


Discussion regarding lmarkus001's framework only. Other posts deleted without notice! :)



Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

Previous topic | Next topic 

  Print view

Author Message
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12111
Location: Tampa, FL
 Post subject: Re: PF statblock importer
PostPosted: Sat May 22, 2010 4:06 pm 
Nope, we want the parens because they create a regex group that can be extracted from the string as a match.


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 3:11 pm 
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:
[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)]
   }
]



I ran into a problem with the above.

It works for most situations because they look like this:

Quote:
hp 92 (8d10+48)
Fort +12, Ref +5, Will +10


But some look like this:

Quote:
hp 92 (8d10+48); regeneration 5 (fire or acid)
Fort +12, Ref +5, Will +10


So, how do I get it to stop at the semi-colon OR "Fort"?

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12111
Location: Tampa, FL
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 3:54 pm 
Full Bleed wrote:
So, how do I get it to stop at the semi-colon OR "Fort"?

Remove the trailing .?Fort and that should do it.


Top
 Profile  
 
User avatar  Offline
Dragon
 
Joined: Sun Jun 15, 2008 1:40 pm
Posts: 444
Location: Montréal, QC
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 4:04 pm 
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.)


Here's the regex I've been using to extract die rolls with pluses, inside parentheses:
\\([-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 ]


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 5:21 pm 
Azhrei wrote:
Full Bleed wrote:
So, how do I get it to stop at the semi-colon OR "Fort"?

Remove the trailing .?Fort and that should do it.


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. ;)


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."


Top
 Profile  
 
User avatar  Offline
Site Admin
 
Joined: Mon Jun 12, 2006 12:20 pm
Posts: 12111
Location: Tampa, FL
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 8:31 pm 
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. ;)

Huh?

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. ;)


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Thu Jun 24, 2010 9:23 pm 
Azhrei wrote:
Try this instead:

hp ([0-9]+).(\\((.+?)\\))?


That did the trick! Thanks. :)

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 3:34 pm 
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:

Code:
[H: id = strfind(statblock, "warrior ([0-9]+)")]


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.

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 3:39 pm 
Something like:

Code:
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]


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.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 4:06 pm 
Rumble wrote:
Something like:

Code:
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]



Thanks. Works great. :)


Quote:
If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.


And thanks for the links. Beats the heck out of trial and error in MT!

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 4:10 pm 
Full Bleed wrote:
Rumble wrote:
Something like:

Code:
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]



Thanks. Works great. :)


Quote:
If you've never used it, I find RegExr and Java Regular Expression Test Applet invaluable for this stuff.


And thanks for the links. Beats the heck out of trial and error in MT!


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.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
 Offline
Great Wyrm
 
Joined: Tue May 26, 2009 7:51 pm
Posts: 2060
Location: Philadelphia, PA
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 7:19 pm 
Be careful as there are some multi-class NPC's and I am not certain this grabs the true class level in that case.


Top
 Profile  
 
User avatar  Offline
Deity
 
Joined: Tue Jul 01, 2008 6:48 pm
Posts: 6237
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 7:31 pm 
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.


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.

_________________

What I'm Working On

MapTool Tutorials:
Introduction to Tokens
Introduction to Properties
Introduction to Macro Writing
Introduction to Light and Sight


Top
 Profile  
 
User avatar  Online
Demigod
 
Joined: Sun Feb 25, 2007 11:53 am
Posts: 3841
Location: MD
 Post subject: Re: PF statblock importer
PostPosted: Fri Jun 25, 2010 11:13 pm 
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.


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.

_________________
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."


Top
 Profile  
 
User avatar  Offline
Great Wyrm
 
Joined: Sat Feb 13, 2010 2:35 am
Posts: 1001
Location: California
 Post subject: Re: PF statblock importer
PostPosted: Sat Jun 26, 2010 2:11 pm 
Rumble wrote:
Something like:

Code:
[h:id = strfind(statblock, "cleric.*?([0-9]+)")]


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.


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.

_________________
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."


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 104 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 243 on Sun Nov 04, 2012 6:14 am

Users browsing this forum: No registered users and 1 guest





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

Style based on Andreas08 by Andreas Viklund

Style by Elizabeth Shulman