maptool
maptool copied to clipboard
[Feature]: Allow a text file to be dragged from the Library onto a map as a token through which the text data (any form of text data) can be accessed and parsed.
Describe the Problem
I'm thinking about porting my PF1e framework to PF2e. To do that, I would like to parse character sheet data from a text file and it makes the most sense to me to have that data associated with a token -- like Hero Lab tokens made from Hero Lab POR files work in MapTool.
In PF1e, I parse the character sheet for a Hero Lab token using the API functions provided for MapTool for Hero Lab. The data is in the form of XML.
**For PF2e, the data will be in JSON and I want to use the MapTool API functions to parse the data (they already provide the ability to parse JSON using the json.path functions). I want to drag-and-drop the text file for each token onto a map. Then, I want to run my macros on the token to import the data -- just like I do for PF1e. BTW, I'm going to get the JSON data from Hero Lab Online for PF2e.
Note, however, that today I want to process JSON data. Tomorrow, it could be something else -- so the goal here is to, first, provide easy access to the text data file associated with a token by dragging the text data file (*.txt extension) onto a map to create the token. Then, allow that data to be accessed through the token.**
The Solution you'd like
For PF1e, I do the following:
- User makes Hero Lab POR file (*.por) resources available to the Library window by adding the directory where it is located.
- The Library window shows each expanded *.por file as tokens that can be dragged onto a map and manipulated there.
- The user invokes one of my macros that sets the desired token as the current token via "[h:switchToken(tokenId)]" and makes use of the herolab.XPath function (a MapTool function). For example:
[h:localBAB = herolab.XPath('/document/public/character/attack/@baseattack')]
[h:localRace = herolab.XPath('/document/public/character/race/@name')]
[h:localSizeFromSheet = herolab.XPath('/document/public/character/size/@name')]
[h:localMovementBaseSpeed = herolab.XPath('/document/public/character/movement/basespeed/@value')]
[h:localMovementWithArmor = herolab.XPath('/document/public/character/movement/speed/@value')]
[h:localStrength = herolab.XPath('/document/public/character/attributes/attribute[@name="Strength"]/attrvalue/@base')]
[h:localDexterity = herolab.XPath('/document/public/character/attributes/attribute[@name="Dexterity"]/attrvalue/@base')]
[h:localConstitution = herolab.XPath('/document/public/character/attributes/attribute[@name="Constitution"]/attrvalue/@base')]
[h:localIntelligence = herolab.XPath('/document/public/character/attributes/attribute[@name="Intelligence"]/attrvalue/@base')]
[h:localWisdom = herolab.XPath('/document/public/character/attributes/attribute[@name="Wisdom"]/attrvalue/@base')]
[h:localCharisma = herolab.XPath('/document/public/character/attributes/attribute[@name="Charisma"]/attrvalue/@base')]
[h:localMaxHP = herolab.XPath('/document/public/character/health/@hitpoints')]
[h:localHP = herolab.XPath('/document/public/character/health/@currenthp')]
[h:localNonlethalDamage = herolab.XPath('/document/public/character/health/@nonlethal')]
For PF2e, I'd like to be able to do the same thing, except use json.path related function calls -- and the problem that needs to be solved here is to allow me to drag a text file as a token onto a map and provide access to the data from the text file that's associated with the token.
Alternatives that you've considered.
I've considered copying and pasting text data into the Edit Token dialog and processing it from there, but this would take too long and it's too much work.
Additional Context
This feature should be a general purpose feature enabling framework developers to process text file data of any form with their macros. It happens that for my case, it will be JSON data -- but someone else might want a CSV file or a file with text in the form of mark-down or something else we don't expect.