io.*

Note: Unless otherwise specified, if a function takes the (optional) argument base, it defaults to system.DocumentsDirectory

Function

Summary

appendFile( dataToWrite, fileName [ , base ] )

Append the contents of string dataToWrite to the file fileName, creating file if it does not exist.

cleanFileName( filename )

Cleans the string filename to ensure it is safe for use as a file name in all OSes targeted by Corona SDK.

exists( fileName [, base ] )

Returns true if path exists.

mkdir( dirName [, base ] )

Make a new directory with the name dirName. (Warning: Parent folders must be created first for compound paths.)

readFile( fileName [, base ] )

Returns contents of file at fileName as string.

readFileTable( fileName [, base ] )

Read the contens of fileName and return it as a table, where each entry is a line from the file. Lines are separated by newline (\n).

repairPath( path )

Changes 'slashes' in path to match current OS specifications.

writeFile( dataToWrite, fileName [ , base ] )

Write the contents of string dataToWrite to the file fileName.

math.*

Function

Summary

getUID( rlen )

Generates and returns a unique ID of length rlen. Warning: With a rlen of 12 or higher, it is extremely unlikely you will get an id collision, but it is your responsibility to track your prior IDs and verify no collision occurs.

haversine_dist( lat1, lng1, lat2, lng2 [, R ] )

Calculate the distance from GPS position to another. Distance is a multiple of R (default is 6373 kilometers == 3961 miles.)

normRot( toNorm ) (number)

Modifies number toNorm and returns equivalent angle in range [0,360).

normRot( toNorm ) (display object)

Modifies display object toNorm, such that rotation is an equivalent value in range [0,360).

Saving & Loading Tables

Note: Unless otherwise specified, if a function takes the (optional) argument base, it defaults to system.DocumentsDirectory

Function

Summary

load( fileName [ , base ] )

Returns table loaded from file (Uses JSON library as intermediary)

prettySave( theTable, fileName [ , base ] )

Saves table to file as human readable JSON.

repairIndicies( theTable )

Repair numeric indicies in table that uses numbers and other values for indexing. Combining index types like this is bad practice if you are going to save() and load() the table. This function repairs the indices after a load.

save( theTable, fileName [ , base ] )

Saves table to file (Uses JSON library as intermediary)

secure_save( theTable, fileName [ , base ] )

Equivalent to save(), but uses ssk.security.* to obfuscate save.

secure_load( fileName [ , base ] )

Equivalent to load(), but uses ssk.security.* to obfuscate save.

stripSave( theTable, fileName [ , base ] )

Saves table to file (Uses JSON library as intermediary)

Table Utilities

Function

Summary

combineUnique( ... )

Combines n tables into a single table containing only unique members from each source table.

combineUnique_i( ... )

Combines n tables into a single table containing only unique members from each source table.