File access (read and write)
Hi, I've done some googling (read and write files site:http://forums.unknownworlds.com/) and I can't seem to find a completely definitive answer as to the current state of working with files and ns2 mods.
What I want to do is make a config file (text encoded, either json or txt). Then I want to read data from it and write out data to it.
I have a workaround in mind if this isn't possible which doesn't involve reading and writing files but isn't exactly ideal (prebaking presets into the mod source code).
So what's the current status on file access for ns2 mods? Back in 2010 I read that there were rumblings to enable something that would let me do what I want to do but I haven't seen anything conclusive as to whether it exists or not.
What I want to do is make a config file (text encoded, either json or txt). Then I want to read data from it and write out data to it.
I have a workaround in mind if this isn't possible which doesn't involve reading and writing files but isn't exactly ideal (prebaking presets into the mod source code).
So what's the current status on file access for ns2 mods? Back in 2010 I read that there were rumblings to enable something that would let me do what I want to do but I haven't seen anything conclusive as to whether it exists or not.
Comments
The game files path can be accessed via game:// and the users temp folder via temp://
For json de-/encoding ns2 includes dkjson ( can be accessed via global json ).
The methods of core/ConfigFileUtility.lua might help you out as-well
Beside that there are various Shared API methods to handle game asset files and to get details about the File System, have for that a look into the docs/api/Shared.json file.
And last but not least there is Script.Load to parse and load lua files from the File System into the Lua VM.
TinyXML is not accessible via FFI links, so you would need to include a lua-based XML parser into your mod (a list of those can be found at the luawiki)