Save parsing for the drones in space game Duskers
- Store save file (universedata.txt) in a variable, e.g.
universedata
let loadedSaveFile = new DuskerSave(universedata);
- Perform edits
let generatedSaveFile = loadedSaveFile.toString()
- Save this string back as universedata.txt
If you only want to parse a specific line, you can use it's own class (e.g. new DuskerDrone('12345', 'FOO=Bar:Fizz=Buzz')
) or pass it as the only line into DuskerSave
Known types are parsed into an Object with it's data in the config property.
Each of these Objects can be .toString
d into their universedata line
To help you get around faster, there are some methods to find related items,
e.g. to find the slots on your ship
loadedSaveFile.PLAYER[0]
.ship(loadedSaveFile) // DuskerObj, your ship
.owns(loadedSaveFile) // Object of Arrays of the different known types
.SLOT // Array of DuskerSlot
e.g. to find which drone has an item
loadedSaveFile.INVITMD[0] // some item
.owner(loadedSaveFile) // Object of Arrays of the different known types
.DRONE // Array of DuskerDrone, in this case either empty or length 1
- Any loss of data caused to your game is your own responsibility. Always keep backups.
- Pull requests welcome