An NPM package for manipulating FGD (Forge Game Data) files.
You can learn more about FGD files here:
- Anatomy of an FGD (and How to Write Your Own) - Valve Developer Union
- FGD - Valve Developer Community
This module can do the following:
- convert FGD to JSON
- convert JSON to FGD
This method takes a string
of FGD, and outputs a JSON object
.
This method takes a JSON object
, and outputs a string
of FGD.
// Import FGD package
const fgd = require('fgd')
// Read FGD file as string
const FGD_TEXT = require('fs').readFileSync(`game.fgd`, 'utf-8')
// Convert FGD string to JSON
let fgdAsJSON = fgd.toJSON(FGD_TEXT)
// Convert JSON back to FGD string
let jsonAsFGD = fgd.fromJSON(fgdAsJSON)
@PointClass = example : "Example Entity"
[
property(string) : "A property with a string type."
]
{
"includes": [],
"entities": [
{
"name": "example",
"type": "PointClass",
"description": "Example Entity",
"properties": [
{
"type": "string",
"name": "property",
"title": "A property with a string type."
}
]
}
]
}
includes
will be an array of filenames to include at the top of the FGD.
This is a quickly modified version of leops' original fgdparser. It adds a two-way converter with JSON, and some other small features and enhancements. If you want to add/optimize any features, feel free to make a pull request.
The fgd package is released under the MIT license.