string

Used to interact with text files.

Reading and saving text files
 function setup()
     local contentsOrNil = string.read(asset.."Hello.txt")
     print("Contents: " .. tostring(contentsOrNil))
     if test == "World" then
         string.save(asset.."Hello.txt", "Hello")
     else
         string.save(asset.."Hello.txt", "World")
     end
 end
string.read(assetKey)

Reads the contents of a file as text.

Parameters:

assetKey (assetKey) – The asset key of the file.

Returns:

The contents of the file.

Return type:

string

string.save(assetKey, text)

Saves text to a file.

Parameters:
  • assetKey (assetKey) – The asset key of the file.

  • text (string) – The text to save.