Zip with support_binary and server_binarysave.
To save try saveBricks(%path)
To load try loadBricks(%path)
http://www.filedropper.com/twobinaryaddonsIt doesn't save anything but basic brick data at the moment as its a test.
So no prints or events or anything QUIET yet.
Alright, so I'm going to be releasing and using a script that enables the writing of binary data to files. Unfortunately you can't use this to write most existing file types, however you can use it to make large files smaller and/or to obfuscate data. I'm going to be releasing a binary save format test shortly after this.
There's a few things to the file format to keep in mind, first is a few sequences:
- 0xFF,0xFF is the character 0xFF, or the escape character
- 0xFF,0xFE is the character 0x0A, or the new line character
- 0xFF,0xFD is the character 0x00, or the null string terminator
- 0xFF,0xFC is the character 0x0D, or the carriage return
- 0xFF,0xFB signifies the end of a file.
On the lowest level of reading and writing data these escape sequences are accounted for, if you're using this you don't even need to know this is a thing.
The script also supports the saving of complex data types:
- Type 3 is a signed three byte integer, that is a number from roughly -8.3 million to positive 8.3 million
- Type 4 is a signed one byte character, that is a number from -127 to 127
- Type 5 is an unsigned one byte character, that is a number from 0 to 255
- Type 6 is an unsigned 4 byte integer, that is a number from about 0 to 4.2 billion
- Type 7 is a string, which is sort of null terminated, with the escape sequence 0xFF,0xFD instead of an actual 0x00
- There are some array data types in the works too
When using a writeNumber function, the functions will automatically choose the most efficient data type for the number. So any numbers from 0 to 255 for example, won't even use more than two bytes, where as numbers in the millions will. readNumber functions automatically detect datatypes.
API:
- openBinaryFileForRead(%path) --- Returns the binaryFile if successful, 0 on error
- openBinaryFileForWrite(%path) --- Returns the binaryFile if successful, 0 on error
- binaryFile.read() --- Low level function for advanced use, reads next byte. Does translate escape sequences, does not look for objects. Can't be used with readObject on the same file.
- binaryFile.write(%data) --- Low level function for advanced use, writes a byte. Does translate escape sequences, will not make an object. Limited from 0 to 255. This function may not be used with writeArray, writeString, or writeNumber on the same file.
- binaryFile.writeNumber(%number) --- High level function for common use. Writes a number to the file.
- binaryFile.writeString(%string) --- High level function for common use. Writes a string to the file.
- binaryfile.writeArray(%arrayName,%start,%end) --- High level function for common use. Writes an array to a file. The first argument is the name of the variable before the brackets. Start and end are the starting an ending positions. Example: %file.writeArray("$array",0,10) would write the values for $array[0] to $array[10]
- binaryFile.readObject() --- Detects and returns the next object in the file.
- binaryFile.close() --- Writes the buffer if its a write file, closes the file, then deletes the objects. This MUST be done for any write-file you have, or else the last buffer's worth of data won't write to the file. Also works with read-files, but not as required.
- binaryFile.isEOF() --- Returns if the file has been completely read.
Tell me what you think, I'm going to post this probably tomorrow once I've bug tested.
Soon after I'm going to release a binary save format. It should have smaller files and even fix some of the serious problems with the current format.