Starfinder Playlist
  1. #1

    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.
    • 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
    • I did some chaining and linking in the table I got from the user to the values we need.
    • I created a new FGU Builder table with all the XML start and end tags we need. (isidentified is missing in the screenshot as I did that in the aftermath.)
    • I then chained those together and linked them to the data table to get the whole XML data for one item.
      This is the end result:


    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.
    • As this deleted all our end tags we need to create them anew - no problem with Regex.
    • 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.
    • We need to replace those lines with a starting 0, I make them "0abc" because that would be unique for later deletion
    • 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.
    Last edited by Zarestia; June 4th, 2021 at 14:02. Reason: Formatting

  2. #2
    Good stuff!
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Feature Request

  3. #3
    Thanks for the help with my gem items!!!

  4. #4
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,148
    Blog Entries
    9
    Ooh, interesting. This looks very useful. Bookmarked it for later comprehension.

    As for importing excel to FG tables, there is an extension that already does this. Or at least their used to be... I'm not sure what one of these I used in the past, but I used one of them with my 44 trillion dungeon room descriptions module.

    Check these out, it's got to be one of these;
    https://www.fantasygrounds.com/forum...le-Importer-MK
    https://www.fantasygrounds.com/forum...Table-Importer

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in