PDA

View Full Version : Table Maker Utility



Combatwombat
May 21st, 2017, 17:14
Not sure if this is the correct place to post this, so I apologize in advance if it is not.

I was making tables in FG and found that it got a bit annoying after a while, so I exported a few as a mod, dissected them, and wrote a small windows command line utility to take .txt files and turn them into a tables .mod file.

I put the source and the .exe up on Github if anyone is interested in using it.

You just make plain old .txt files with each table entry being on a separate line. You can put a JSON string on the first line to control how the table is created (Table name, number of columns, etc). Put them all in a folder, run the command line tool wiht the correct parameters, and boom, you have a .mod file you can use in FG.

Let me know if there are any questions!

https://github.com/dirtknap/MagicTableMaker/releases

Command Line Arguments:


Required: Source file path (where your stuff goes in): -s "C:\directory name"
Required: Output file path (where your stuff comes out): -o "C:\directory name"
Required: Project name (name of your module): -p "project name"
Required: Filename (what your module file will be named): -f "file name"
Optional: Author (You or your company's name): -a "Your name here"
Optional: Category (Module category): -c "Category name"
Optional: Version (Version of Fantasy Grounds supported. Defaults to 3.3): -v "3.3"
Optional: Release (Release of Fantasy Grounds supported. Defaults to 7|CoreRPG:3): -r "7|CoreRPG:3"



Example Usage:

>MagicTableMaker.exe -o "C:\test" -s "C:\test\tables" -p "Battle Sloth Table" -f "bs_tables" -a "Battle Sloth Software"

This app reads any .txt documents in from the source directory and packages them into a .mod file. The app creates a table entry for each line in the document. By default it names the table after the file name and creates a single column table. You can add a file header JSON string to the first line to control how the app processes the txt file.

Example:

{"Name":"NPC Names","Description":"A bunch of names","Category":"My Tables","Columns":["Male","Female"],"Separator":"|"}

This will create a table with the name NPC Names with a description of A bunch of names. It will be a two column table with the columns being Male and Female. In the Tables dialog in Fantasy Grounds, this table will be in the My Tables list. It expects the dataset in the txt file to have the columns split by the '|' character None of these fields are required and any not present will use defaults.

The defaults are:


Name: txt filename
Description: blank
Category: project name
Columns: blank
Separator: If no separator is specified, it assumes single column table



If you want to specify a ruleset, add a ruleset.txt file to your source directory and put each ruleset you want to specify on a separate line of the text file. Otherwise it defaults to ruleset = Any

LordEntrails
May 22nd, 2017, 05:08
Nice, thanks for sharing. I'm definitely going to be looking into using this :)

iotech
May 27th, 2017, 00:53
CombatWombat,

Great utility!. I'm writing a UI and Editor for it right now. Will link it here when done.

-iotech

Edit: Maybe not WPF. I now remember why I hate WPF.

iotech
May 30th, 2017, 01:52
CombatWombat,

I added a few lines to your source code to allow adding a thumbnail image for the Module. Since you dont have the repo set up for pulls or collaboration, I'm posting here. If interested, change the foreach in ProjectRunner's RUN method to include the following:


foreach (var fileInfo in files)
{
Console.WriteLine($"Processing {fileInfo.Name}.");

if (fileInfo.Name.ToLower().StartsWith("ruleset"))
{
project.Rulesets = FileParser.ParseRulesetFile(fileInfo);
}
else if (fileInfo.Name.ToLower() == "thumbnail.png")
{
//Add thumbnail
string outPath = Path.Combine(project.OutputFilePath, project.FileName, "thumbnail.png");
File.Copy(project.SourceFilePath + "\\thumbnail.png", outPath);
}
else
{
project.Tables.Add(FileParser.ParseTableFile(fileI nfo, project.Name));
}
}

To use, simply add a PNG named "thumbnail.png" to the project folder; it gets copied to the output and added to the .mod file.

Edit: I PM'd you, but got an error. Not sure if it worked or not.

iotech
May 30th, 2017, 01:57
MagicTableMaker GUI coming along nicely. Preview:
19170