scottanderson / railroad.studio

A save file editor for Railroads Online
https://railroad.studio
MIT License
21 stars 10 forks source link

Export/import lists of frames #190

Open RichardDastardly opened 3 months ago

RichardDastardly commented 3 months ago

A handy function ( or button! ) would be one to import ( and export ) lists of frames - my primary need would be preparing pre-laid maps for publishing, if I want to publish an "empty" map I ether have to wipe all frames every time from the console & then buy new ones, or individually delete. I guess I could pre-prepare javascript for the console, but it'd seem easier just to be able to export frames as json & edit them, and then re-import as a native function.

scottanderson commented 3 months ago

The internal data structure RS uses could be exported to JSON easily. You can achieve this in the console with JSON.stringify(studio.railroad.frames, null, 2).

Importing from JSON would require validation that the data conforms to the typescript type Frame. Writing this by hand would be tedious and error prone, so something like zod might be helpful here.