construct.net/en/make-games/manuals/construct-3/plugin-reference/nw-js
See the section in the manual regarding using file paths correctly on the NW.js page.
It recommends writing to NWjs.UserFolder & "myfile.txt"
, however I would additionally recommend putting it in a directory unique to your game, as well as saving the file as .json if you'll be saving data in json format. Alternatively, use an obfuscated/unique/encrypted format you are familiar with.
You want to use the NW.js Write text file
action, with your array.asJSON as the content to write. Or whatever else type/format of data you're saving. Dictionary.asJSON works well as well, and is more similar to LocalStorage in terms of keys and values. Save to your dictionary as you normally would have to LocalStorage, with the additional step of writing the dictionary to disk as a file through NW.js when desired.
To load, you can use the ReadFile()
expression (into your load dictionary or load array action). You can get information about the file location with the NW.js action List files
along with the UserFolder
, ListCount
, and ListAt()
expressions to confirm and validate the existence of save files.