I just wanted to get this out so people can test it. Feel free to delete this once we have a website again.
New script functions:
openfilestream(
"data/filepath/file.txt")
-opens a text file and returns the index that other functions can use to access it. Indexes are assigned in order of creation, from 0 to the maximum number of filestreams (currently 20).
getfilestreamline(
int index)
-Returns the current line of the file as a string, cutting it off if it's larger than the maximum string length.
getfilestreamargument(
int index, int argumentnumber, string returntype);
-Returns the specified argument at the current position. For example, with this line in the file:
Stringargument 1 3.4
you would get these results:
getfilestreamargument(index, 0, "string") -> Stringargument
getfilestreamargument(index, 1, "int") -> 1
getfilestreamargument(index, 2, "float") -> 3.4
getfilestreamargument(index, 2, "int") -> 3
The only problem with this command is that string arguments don't work if they are the last one on the line. So make sure that there is another block of characters of some kind to the right of any string arguments.
filestreamnextline(
int index)
-Moves to the next line of the file that has any characters.
getfilestreamposition(
int index)
-Returns the current position in the file.
setfilestreamposition(
int index, int position)
-Sets the current position. Record a position with getfilestreamposition to go to, or set it to 0 to go back to the beginning of the file.
Basically, this lets you create your own file types for storing data and read them during gameplay. This is very useful for storing data that can't be stored efficiently otherwise, like dialogue or a complex sequence of actions for an entity to take.
There is one important restriction, though; loading a file during gameplay will create a short but noticeable pause while the file loads. For this reason, it's highly recommended to load files in level.c or any other script that doesn't run during the actual gameplay. Reading the file is fast, though, and can be used like any other script command.
Files are automatically unloaded between levels, so you don't have to worry about deallocating them or anything. You will have to load the file in each level that you want to use it in though. I might make an option for having files be able to stay in memory if it turns out to be a big issue, but I can't imagine it would be unless you had a ton of really huge files.
Anyhow, please test it out and report any bugs!