BinaryMachines
This package allows you to create and write your own files anywhere in the file system.
Dependencies
N/A
Initialization
N/A
Implementation
BinaryWriter
BW_NewFile
Creates the file with the file
name and opens a stream. Doesn't work if a stream is already open.
var string file
Name of created file
Return value
The function returns TRUE
if the file is successfully created and initialized, FALSE
is returned otherwise.
BW_Close
Closes the current write stream.
BW
Writes length
bytes from the data
to the stream, maximum 4 bytes.
var int data
Value of bytesvar int length
Number of bytes
BW_Int
Writes 4 bytes from the data
to the stream. Same as BW(data, 4)
.
var int data
Integer value to write
BW_Char
Writes the first character from the data
to the stream. Same as BW(Str_GetCharAt(data, 0), 1)
.
var string data
Char to write
BW_String
Writes the data
terminated with \0
to the stream.
var string data
String to write
BW_Byte
Writes a byte from the data
to the stream. Same as BW(data, 1)
.
var int data
Byte value to write
BW_Bytes
Writes length
of bytes from the pointer dataPtr
to the stream.
var int dataPtr
Pointer of data to writevar int length
Number of bytes
BW_Text
Writes the string to the stream without terminating it. So it can no longer be read.
var string data
Text to write
BW_NextLine
Writes a paragraph to the stream.
BinaryReader
BR_OpenFile
Opens the file with the file
name and opens a stream. Doesn't work if a stream is already open.
var string file
File to be opened
Return value
The function returns TRUE
if the file is successfully opened and initialized, FALSE
is returned otherwise.
BR_Close
Closes the current read stream.
BR
Reads bytes from the stream.
var int length
Number of bytes to read (maximum 4)
Return value
The function returns the value of read bytes.
BR_Int
Reads 4 bytes from the stream. Same as BR(4)
.
The function returns the read integer.
BR_Char
Reads a character from the stream. Same as BR(1)
.
The function returns the read character as a string
.
BR_String
Reads a string terminated by \0
from the stream.
The function returns the read string.
BR_Byte
Reads a byte from the stream.
The function returns the read byte.
BR_Bytes
Reads bytes from the stream.
var int length
Number of bytes to read
Return value
The function returns a pointer to the read bytes.
BR_TextLine
Reads a line from the stream.
The function returns the read line.
BR_Text
Reads a string of the given length from a stream.
var int length
Number of characters to read
Return value
The function returns the read string.
BR_NextLine
Changes the read position to the next paragraph, created with BW_NextLine
Enginecalls
WIN_GetLastError
Call of a Win32 API GetLastError
function
The function returns calling thread's last-error code.
WIN_CreateFile
Call of a Win32 API CreateFileA
function
Full description of parameters can be found here
Return value
Information about return value can be found here
WIN_WriteFile
Call of a Win32 API WriteFile
function
Full description of parameters can be found here
WIN_ReadFile
Call of a Win32 API ReadFile
function
Full description of parameters can be found here
WIN_CloseHandle
Call of a Win32 API CloseHandle
function
Full description of parameters can be found here
WIN_GetFileSize
Call of a Win32 API GetFileSize
function
Full description of parameters can be found here
Return value
Information about return value can be found here
Constants
In addition there are some constants defined for use with the specific engine calls.
Examples
Save and load variables
Congratulate the player
The location of an NPCs
Note
Examples originally written by Gottfried and posted on World of Gothic forum.