LevelData.lua

Download Latest Version

LevelData is a small library which wraps around the UserData functions, making level-specific variables easier to manage.

Installation
Drop the LevelData.lua file in the LuaScriptsLib folder.

How to use
First, load in the API. Then you can use LevelData functions as you would use UserData functions, to save, load, and manage custom saved variables.

Example
This will increment a value saved in the UserData variables, but crucially, the same value can be used in multiple levels, and will not clash with each other, allowing each level to keep track of their own variable. If used on the overworld, this library will also create a variable for the overworld.

External Use Functions
These are functions you will need to use the library

{| class="wikitable" border="0" !getValue !Key The key used to save the value to the data bank. !setValue !Key !Value The key to save the value to the data bank. The value to assign to this key. !isValueSet !Key The key used to save the value to the data bank. !values !save !externalData !levelName The name of the filename for the level whose data you wish to access (do not include ".lvl" on the end of this).
 * Gets a value saved to this level's data bank.
 * number or nil
 * string
 * number or nil
 * string
 * Sets a value in this level's data bank to the specified value.
 * nil
 * string
 * string
 * number
 * Determines whether or not a value has been saved to this level's data bank.
 * boolean
 * string
 * string
 * Returns a list of all keys in this level's data bank.
 * table(string,number)
 * Returns a list of all keys in this level's data bank.
 * table(string,number)
 * Flushes the data to the external text file, ensuring that it can be read back later.
 * nil
 * Flushes the data to the external text file, ensuring that it can be read back later.
 * nil
 * Creates a new LevelData object, which allows access to a level defined by the levelName variable. For example, if levelName is given as "Level", this object will access variables saved for Level.lvl. To access data for the overworld, this should be set to ".MAP".
 * LevelData
 * string
 * string
 * -}