Game Development Reference
In-Depth Information
io.flush ( )
This function runs file:flush() on the default file. When a file is in buffered mode, the data is not
written to the file immediately; it remains in the buffers and is written when the buffer nears getting
full. This function forces the buffers to write to file and clear up.
io.input ( [file] )
This function returns the current default input file when called without any parameters. The parameter
passed can be either a filename or a file handle. When the function is called with a filename, it sets
the handle to this named file as the default input file. If it is called with a file handle, it just sets the
nil .
io.lines is called without a filename, it is equivalent to io.input():lines() , and it reads from
for line in io.lines(filename) do
print(line)
end
io.open ( filename [,mode] )
This function is the main function that you use in reading and writing files with Lua. The mode is a
string value that can be one of the following:
"r" : Read mode (default).
"w" : Write mode.
"a" : Append mode.
"r+ " : Update mode. All previous data is preserved.
"w+ " : Update mode. All previous data is erased.
"a+ " : Append update mode. All previous data is preserved and writing is only
allowed at the end of the file.
The mode can also have a "b" at the end to indicate that the file is to be opened in binary
mode rather than in text mode. This function returns a file handle that can be used in explicit file
operations.
file = io.open("myfilename.txt", "r")
 
Search WWH ::




Custom Search