@etothepii/satisfactory-file-parser
Advanced tools
Comparing version 0.0.16 to 0.0.17
{ | ||
"name": "@etothepii/satisfactory-file-parser", | ||
"author": "etothepii", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"description": "A file parser for satisfactory files. Includes save files and blueprint files.", | ||
@@ -6,0 +6,0 @@ "module": "Node16", |
@@ -22,9 +22,11 @@ # Satisfactory File Parser | ||
`npm install @etothepii/satisfactory-file-parser` | ||
## Usage | ||
Usage of the SaveParser is easy. For reading a save file, just pass a Buffer to it. | ||
## Usage of Save Parsing | ||
Usage of the SaveParser is easy. For reading a save file (`.sav`), just pass a Buffer to the parser with the file content. | ||
```js | ||
import { SaveParser } from "@etothepii/satisfactory-file-parser"; | ||
import * as fs from 'fs'; | ||
import { Parser } from "@etothepii/satisfactory-file-parser"; | ||
const file = fs.readFileSync('./MySave.sav') as Buffer; | ||
const parsedSave = SaveParser.ParseSaveFile(file); | ||
const parsedSave = Parser.ParseSaveFile(file); | ||
``` | ||
@@ -37,6 +39,9 @@ | ||
```js | ||
import { SaveParser } from "@etothepii/satisfactory-file-parser"; | ||
import * as fs from 'fs'; | ||
import { Parser } from "@etothepii/satisfactory-file-parser"; | ||
let header, bodyChunks; | ||
SaveParser.WriteSave(save, binaryBeforeCompressed => {}, header => { | ||
let header, bodyChunks = []; | ||
Parser.WriteSave(save, binaryBeforeCompressed => { | ||
console.log('on binary data before being compressed.'); | ||
}, header => { | ||
console.log('on save header.'); | ||
@@ -47,8 +52,41 @@ header = header; | ||
bodyChunks.push(chunk); | ||
}, summary => { | ||
console.log('finished writing chunks.'); | ||
}); | ||
// write complete sav file back to disk | ||
fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header, ...bodyChunks])); | ||
// write complete sav file back to disk | ||
fs.writeFileSync('./MyModifiedSave.sav', Buffer.concat([header, ...bodyChunks])); | ||
``` | ||
## Usage of Blueprint Parsing | ||
Blueprint parsing works very similiar. Note, that blueprints consist of 2 files. The `.sbp` main file and the config file `.sbpcfg`. | ||
```js | ||
import * as fs from 'fs'; | ||
import { Parser } from "@etothepii/satisfactory-file-parser"; | ||
const mainFile = fs.readFileSync('./MyBlueprint.sbp') as Buffer; | ||
const configFile = fs.readFileSync('./MyBlueprint.sbpcfg') as Buffer; | ||
const parsedBlueprint = Parser.ParseBlueprintFiles('MyBlueprint', mainFile, configFile); | ||
``` | ||
Consequently, writing a blueprint into binary data works the same way with getting callbacks in the same style as the save parsing. | ||
```js | ||
import * as fs from 'fs'; | ||
import { Parser } from "@etothepii/satisfactory-file-parser"; | ||
let mainFileHeader, mainFileBodyChunks = []; | ||
const summary = Parser.WriteBlueprintFiles(blueprint, mainFileBinaryBeforeCompressed => { | ||
console.log('on main file binary data before being compressed.'); | ||
}, header => { | ||
console.log('on main file blueprint header.'); | ||
mainFileHeader = header; | ||
}, chunk => { | ||
console.log('on main file blueprint body chunk.'); | ||
mainFileBodyChunks.push(chunk); | ||
}); | ||
// write complete .sbp file back to disk | ||
fs.writeFileSync('./MyModifiedBlueprint.sbp', Buffer.concat([mainFileHeader, ...mainFileBodyChunks])); | ||
// write .sbpcfg file back to disk, we get that data from the result of WriteBlueprint | ||
fs.writeFileSync('./MyModifiedSave.sbpcfg', Buffer.from(summary.configFileBinary)); | ||
``` | ||
@@ -55,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193493
94