HomeIndex

System/File Functions

appendfile(filename, string)
Appends the filename with a string
If the file doesn't exist, it is created. A full path to the file is needed. This function is exclusively for debugging and development. Data saved for the player should go though getuserpref and the like.
appendfile("User/Sally/Desktop/debug.txt", debug_output_string)
There is currently no way to delete a file or overwrite a file.
gametime()
Returns the number of seconds the game has been running.
local seconds = gametime()
This value is not saved or loaded, so it is the time since the player last started the game.
microtime()
Returns the number of milliseconds seconds the game has been running.
This command is primarily for development and debugging.
systemtime()
Returns the unix time for the device running the game.
Unix time is the number of seconds since 1970.
strtime(format, unixtime)
Returns a string of unixtime using format
print(strtime("%F", systemtime()))
While unixtime is based on GMT, strtime converts to local time.
The strtime command uses the format of the C strftime() function.
Documentation can be found at http://www.cplusplus.com/reference/ctime/strftime/
loadtsvtable(assetname,percents=false)
Returns a table of a .tsv file.
The first column is the key and the other columns form a key in a sub-table.
A .tsv file of...
key area level ice_goblin1 ice 3 ice_goblin2 ice 3 orc2 grass 1
Loads a table of...
{ ice_goblin1 = { area = "ice", level = 3 } ice_goblin2 = { area = "ice", level = 3 } orc2 = { area = "grass", level = 1 } }
Empty cells return null. Values in the form of 100% and 25% return 1.0 and 0.25 if percent is true Cells that can be a valid int or float are converted, everything else will be a string. If percent is true then values like 25% are returned as 0.25
loadtsvarray(assetname)
Returns an array of a .tsv file.
A .tsv file of...
key area level ice_goblin1 ice 3 ice_goblin2 ice 3 orc2 grass 1
Loads an array of tables... [
{ key = "ice_goblin1", area = "ice", level = 3 } { key = "ice_goblin2", area = "ice", level = 3 } { key = "orc2", area = "grass", level = 1 }
]
Empty cells return null.
Values in the form of 100% and 25% return 1.0 and 0.25.
Cells that can be a valid int or float are converted, everything else will be a string.
loadarray(assetname)
Returns an array of strings from a file.
A .txt file of...
Ray Reys Franklin Delores Ransome
After running
local a = loadarray("names.txt")
The array a is now... [
"Ray" "Reys" "" "Franklin" "Delores" "Ransome"
]
Empty lines return "". All whitespace is trimmed from the end of lines.
assetexists(assetname) | assetexists(sheet, image)
Returns true if the asset exists.
No path is needed since it is checking within the uniquely named game assets. During development these will be lose on the disk, but for release they will be in .ggpack files.
if (assetexists("HelpScreen.png") { ... }
The command can also check if an image exists in the sprite sheet.
if (assetexists("Interface", "ps4Button") { ... }
quitgame()
Quits the game cleanly.
quitgame()