How-to: Creating a module out of an Excel/Calc table
Yesterday, I read a post in the Fantasy Grounds College discord asking how to easily create items in Fantasy Grounds as that person created an Excel table with around 800 entries.
Today I want to show you how I created a module containing 801 items in about half an hour (had to fix that table a bit before starting). This works with Excel, Libre Calc, etc. and is best suited for anything that works logically in a table format (items, feats, spells [automation is another topic], etc.) and you have hundreds of, it's scalable.
For this example i use D&D 5e and gemstones as items. My workflow for sure has some things which can be made better but it works for me as this is all self-thaught.
Step 1: Inspect the data structure of the entries you want to create
- Create a test campaign, DND 5e, no extensions.
- Create an item with and hit /export in the chat when you're done.
- Fill out your information and tick the data entries which you want to export.
https://i.imgur.com/90iEbLW.jpg - Navigate to your modules folder (default: %appdata%\SmiteWorks\Fantasy Grounds\modules) and unzip the created module.
- Open the db.xml in an IDE or somehting like Notepad++.
We can see this code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<root version="4.1" dataversion="20210302" release="8.1|CoreRPG:4.1">
<item>
<id-00001>
<ac type="number">0</ac>
<bonus type="number">0</bonus>
<cost type="string">10 gp</cost>
<description type="formattedtext">
<p />
</description>
<isidentified type="number">0</isidentified>
<locked type="number">1</locked>
<name type="string">Azurite</name>
<nonid_name type="string">Blue Gemstone</nonid_name>
<subtype type="string">Gemstones (10 Gp)</subtype>
<type type="string">Treasure</type>
<weight type="number">0.01</weight>
</id-00001>
</item>
<library>
<dataentrymodule static="true">
<categoryname type="string">Supplement</categoryname>
<name type="string">dataentrymodule</name>
<entries>
<item static="true">
<librarylink type="windowreference">
<class>reference_list</class>
<recordname>..</recordname>
</librarylink>
<name type="string">Items</name>
<recordtype type="string">item</recordtype>
</item>
</entries>
</dataentrymodule>
</library>
</root>
We can omit the tags for ac, bonus and description as we don't need them for our items in this case.
We need values for the following things: - Name
- Unidentified Name
- Cost
- Locked
- Type
- Subtype
- Weight
Step 2: Prepare our table
Step 3: XML editing with Regex
- I copy our end result to a new document in Notepad++
- As every item is only one row we need to split those up. We do this for every tag.
https://i.imgur.com/C2fklYV.jpg - As this deleted all our end tags we need to create them anew - no problem with Regex.
https://i.imgur.com/TS49PCt.jpg - Lastly, we need to create an ID for every item. For Notepad++ I've written a short python script which can be executed with the python plugin. Everything starting in a new line with 0 gets replaced with IDs.
Code:
i=-1
def increment(match):
global i
i=i+1
return "</id-"+str(i)+"><id-"+str(i+1)+">"
editor.rereplace('^(?=0)', increment)
- We need to create new lines, before every name tag.
https://i.imgur.com/gMRB0YX.jpg - We need to replace those lines with a starting 0, I make them "0abc" because that would be unique for later deletion
https://i.imgur.com/45y199x.jpg - We now execute our little script and voilá, we got IDs wrapped around every item, need to clear up the first and last item.
- Lastly, delete "0abc" with a simple replace as none.
Step 4: Wrap it up in a module
- Grab the extracted db.xml again and look for the code before the actual data.
Code:
<?xml version="1.0" encoding="utf-8"?>
<root version="4.1" dataversion="20210302" release="8.1|CoreRPG:4.1">
<item>
and
Code:
</item>
<library>
<dataentrymodule static="true">
<categoryname type="string">Supplement</categoryname>
<name type="string">dataentrymodule</name>
<entries>
<item static="true">
<librarylink type="windowreference">
<class>reference_list</class>
<recordname>..</recordname>
</librarylink>
<name type="string">Items</name>
<recordtype type="string">item</recordtype>
</item>
</entries>
</dataentrymodule>
</library>
</root>
- Copy your create data into the db.xml bewteen those two parts, overwriting the one old item. Save the file.
- Zip the definition.xml and db.xml and rename the module however you want, it needs to have the ending .mod
- Load it up in Fantasy Grounds.
I hope this helps someone out when entering many data entries into Fanatsy Grounds. If there are questions or improvement suggestions, ask away. You don't need excel or calc data, I used nearly the same XML workflow for creating 1k spells for my D&D 3.5 Spell Compendium module, just had to copy every spell into Notepad++. Still way faster than typing 1.000 spells manually into Fantasy Grounds. This whole things might seem much but once you've done it, it is rather easy.