PDA

View Full Version : Help Pls Modifying String Parser



Myrddin
July 14th, 2013, 01:26
I am modifying the 3.5E ruleset for Pendragon and I want to modify the string parser within the 3.5E ruleset.

Instead of the syntax for Skill entries on the NPC sheet requiring a skill name, sign and a value for the skill modifier, I want to simply allow the skill name and value to be recorded. For example, instead of Hunting +10 I want to write the entry as Hunting 10.

I have identified the line of code which I need to modify within the campaign_npc_skill.lua file:



local nStarts, nEnds, sLabel, sSign, sMod = string.find(aClauses[i], "([%w%s\(\)]*[%w\(\)]+)%s*([%+%-–]?)(%d*)");


However, I am struggling to adjust it to work as I intend. Can anybody give me any pointers?

Trenloe
July 14th, 2013, 02:04
I don't know if this will work for you:


([%w%s\(\)]*[%w\(\)]+)%s*(%d*)

Removing the portion that looks for a + or -.

Myrddin
July 14th, 2013, 02:13
I tried that first. It doesn't quite work. The string.find function now returns the value as part of the label and finds nil for the modifier value.

Trenloe
July 14th, 2013, 02:18
Remove sSign from the variable list as this will no longer be returned.

Myrddin
July 14th, 2013, 02:23
Yep, tried that too. Still same problem.

Trenloe
July 14th, 2013, 02:28
Sorry, one minor change. The %w (alphanumeric match) needs to be changed to %a (only letters match).

Try this:

([%a%s\(\)]*[%a\(\)]+)%s*(%d*)

I'm not familiar with the skills in Pendragon (it's been many, many moons since I played). As long as the skills are purely words made up of only letters then this should be OK.

Myrddin
July 14th, 2013, 02:34
Yaay! Success. Thanks a bunch Trenloe.

Skills in PD are purely words, so this should work a treat.