Tinderbox Forum

Automatic string manipulation/parsing

I am using Tinderbox to organize my data around a tabletop RPG I am running for remote friends. One of the games uses a virtual tabletop that requires a specific text format for character sheets. I have an enormous body of character sheets that are more or less consistently formatted.

Is there a way using Tinderbox to parse all or part of these sheets automatically so that they are converted to the needed format? For example a way to make it so when I paste"Acrobatics (+12)" to a note and perform some operation, it changes the text to “Acrobatics +12”. I can for sure manually apply some string manipulation to the text and do it myself, but if I could automate it, then I could ultimately figure out how to convert my existing data into the XML format used by the game. that would allow me to do mass imports of characters rather than copying and pasting section by section. But you gotta start somewhere.

thanks all!

Christopher Hatty

There’s quite a lot of support in Tinderbox for taking semi-structured text like

Acrobatics: 12
Aeronautic Engineering: 6

and extracting things to attributes like $Acrobatics. Once done, it’s then easy to write agents for things like “All characters who have good acrobatics and know how to repair an ornithopter." And it’s easy to write export templates for the XML.

For simple formats, you’ll want to check out [String].following(), which is limited but very easy to use. For more complex situations, consider regular expressions and [String].contains().

This is a complete list of available actions. Hopefully it may give you some ideas.

Export to XML is definitely possible, I’ve done it in the past.

thanks all. I am hoping to dig into this this weekend. I will post follow up questions here unless you think a new thread is appropriate!

1 Like

what might be useful is to see a sample of the source data you’re passing to Tinderbox and to understand how you are getting it into Tinderbox. Rather than paste big bits of text and then play regex games to find things, consider tab-delim/CSV input allowing you to map data directly to Tinderbox attributes.

For instance, if you made a table in the source app and had a column ‘Acrobatics’, then you could make a Number-type user attribute Acrobatics and each row would store the Acrobatics column value as that notes’ $Acrobatics. In the example you give, the value would be 12 but it could be -0.05 or such.

To see a note’s $Acrobatics, you’d add the ‘Acrobatics’ attribute as a Displayed Attribute for the notes.

If the above appeals, don’t worry about doing it all right the first try. start with one or two columns and data of a few different types (numbers, text, lists boolean (true/false), etc.) and build out from that.

With a little experimentation you can circumvent the painful process of having everything in a note’s text ($Text) and having to excavate it with regex. There are lots of neat action code operators like the ones already suggested in 2Eastgate’s answer (only some using regex).

Good luck and do come back with questions. Fine to start here, but if you’ve a number of discrete questions it can be helpful (especially for later readers) if we explore them in separate trhreads with explanatory titles.

I haven’t had much time to play with this, for complicated plot reasons.
Probably will at some point though.
Now I am on to simpler tasks like trying to figure out how to use agents to add captions to images.

Captions where? alt text for HTML, captions under an image in an export template, somewhere else?

I’f you’ve a link to the XML format and small demo TBX file showing your starting info, with a note saying what in the TBX goes where in the XML and sure fellow users can help you out.

1 Like

I am going to get my terminology wrong.

the General attribute category has an attribute called Caption, which was that I was talking about. I am playing around with how to present data to myself so I can easily find and identify a character, location, event, etc. I had been considering dragging an image for an NPC into the map and then using its caption to identify it. Then I realized it might be better to drag the image into the note text. Not sure if it is or isn’t, but the goal is to create an agent that will copy the name of the note to the Caption of the note.

But this is off topic :slight_smile: I will create a new topic a little later.

Thanks!

Thanks. Don’t forget, few—if any of us will know your desired XML output format. It there a link to an example XML page or documentation? :slight_smile:

Sadly there’s no useful XML reference I can find for Fantasy Grounds (the virtual tabletop in question). If I CAN find it I will share!

My apologies, I misunderstood as your opening post implied an XML format was involved. No matter, we can help you with how to export an attribute (including $Text) into an XML value. However, it sounds like the first thing you need is the game’s file format otherwise you’re not much further forward. For instance, something like lists may need formatting using a particular delimiter, so it helps to know that; or are numbers stored as integers or with decimal places, etc. Perhaps the game has a forum where someone can point you to the game’s XML data storage format.

Anyway, good luck!

Thanks Mark!