pilotofsomething 1 Posted April 19, 2017 Share Posted April 19, 2017 An API that makes creating and reading configuration files easier. Any line starting with a '#' is ignored in config files. Documentation: loadConfig(string: path) Returns a stream of the file the path points to. saveConfig(string: path) Creates a config file at the given path. If a config file with the same name already exists it will be overwritten. flush() Clears all properties currently in memory. addProperty(string: name, value) Adds a property to the config. Note that the order properties appear in the config is the same order that the functions are called in. addComment(string: text) Adds a comment to the config. Comments are lines that start with '#', you could do this with addProperty, but this saves memory and doesn't add an '=' at the end of the line. getNumber(stream: file, string: name): number Returns the value of property 'name' as a number. getBoolean(stream: file, string: name): boolean Returns the value of property 'name' as a boolean. getString(stream: file, string: name): string Returns the value of property 'name' as a string. Download: pastebin get wE9xT51N /lib/config.lua Quote Link to post Share on other sites
xilni 1 Posted June 15, 2017 Share Posted June 15, 2017 Good job, I took a quick look at your code. Small efficient library that does one thing and seems to do it well, I look forward to trying it out in my program. Quote Link to post Share on other sites