Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Recommended Posts

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

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.