Repository navigation
Scripting FileSystem
-
AOFenum - Flags for animation playback:-
AOF.PAUSED- Pause animation on the first frame -
AOF.LOOPING- Make animation loop -
AOF.NORESTART- Don't restart the current animation from the first frame if playing the same animation again -
AOF.SMOOTHCHANGE- Smoothly change from the last animation instead of immediately starting a new one
-
-
SEEKenum - Types for seeking position within streams:-
SEEK.SET- Seek position from the beginning of the stream -
SEEK.CUR- Seek position from the current offset within the stream -
SEEK.END- Seek position from the end of the stream
-
Class for representing a loaded font file.
Constructs a new font by loading it from the specified file.
Arguments:
-
file- Path to the.fntfile to load.
Returns path to the texture file used by the font. Equivalent to the engine's
CFontData::fd_fnTexture.
Return value: string
Returns maximum width of any character in the font in pixels. Equivalent to the engine's
CFontData::GetWidth().
Return value: integer
Returns maximum height of any character in the font in pixels. Equivalent to the engine's
CFontData::GetHeight().
Return value: integer
Specifies standard spacing between each character in pixels. Equivalent to the engine's
CFontData::fd_pixCharSpacing.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
integer |
Font-dependent | Yes | Yes |
Specifies standard spacing between each line in pixels. Equivalent to the engine's
CFontData::fd_pixLineSpacing.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
integer |
Font-dependent | Yes | Yes |
Whether the font should be monospace. Equivalent to the engine's
CFontData::fd_bFixedWidth.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
Font-dependent | Yes | Yes |
Class for representing a loaded texture.
Constructs a new texture by loading it from the specified file.
Arguments:
-
file- Path to the.texfile to load.
Start next available animation in the list.
Return value: null
Start previous available animation in the list.
Return value: null
Skip to the next frame in the current animation.
Return value: null
Revert to the previous frame in the current animation.
Return value: null
Reset the current animation to the first frame.
Return value: null
Reset the current animation to the last frame.
Return value: null
Get current frame of the current animation.
Return value: integer
Get the exact point between two current frames of the animation during rendering. Returns an array with the current frame, the next frame and the current progress between both.
Return value: array with three values:
-
integer- Index of the current frame. -
integer- Index of the next frame (may not always be "current + 1"). -
float- The current progress between the two frames from0.0to1.0.
Get amount of animations in the texture.
Return value: integer
Get information about the specified animation. Returns an array with the animation name, amount of frames and the time between each frame in seconds.
Arguments:
-
anim- Index of the animation to check.
Return value: array with three values:
-
string- Animation name. -
integer- Amount of frames in the animation. -
float- Time between each frame in seconds.
Get length of the specified animation in seconds.
Arguments:
-
anim- Index of the animation to check.
Return value: float
Get index of the current animation.
Return value: integer
Get amount of frames in the current animation.
Return value: integer
Get length of the current animation in seconds.
Return value: float
Change playback speed of the specified animation from the predefined value.
Arguments:
-
anim- Index of the animation to modify the speed of. -
speed- New amount of seconds between each frame to set. For example, for a 30 FPS animation this value is0.033333.
Return value: null
Start playing a new animation with specific flags.
Arguments:
-
anim- Index of the animation to play. -
flags- Animation flags from theAOFenum.
Return value: null
Smoothly switch to a different animation.
Arguments:
-
anim- Index of the animation to switch to.
Return value: null
Pause currently playing animation. Sets
AOF.PAUSEDflag to it.
Return value: null
Continue currently paused animation. Removes
AOF.PAUSEDflag from it.
Return value: null
Check whether the current animation is paused.
Return value: bool
Check whether the current non-looping animation has finished playing.
Return value: bool
Skip to the specified time in the current animation.
Arguments:
-
time- Time to skip to in seconds.
Return value: null
Offset the current animation by a certain amount of seconds.
Arguments:
-
time- Amount of seconds to offset the animation by.
Return value: null
Get time from when the animation started playing in seconds.
Return value: float
Get texture width in meters.
Return value: float
Get texture height in meters.
Return value: float
Get texture width in pixels.
Return value: integer
Get texture height in pixels.
Return value: integer
Get texture flags.
Return value: integer
Class for representing a file stream for reading data from disk.
Opens an existing file using the specified path relative to the game directory either from disk or from any loaded GRO archive for reading data. Equivalent to the engine's
CTFileStream::Open_t().
Arguments:
-
path- Path to the file to open.
Return value: null
Closes any open file, finishing the writing/reading procedure. Equivalent to the engine's
CTFileStream::Close().
Return value: null
Returns whether the stream is currently open for some file.
Return value: bool
Returns path of the currently open file. Equivalent to the engine's
CTStream::GetDescription().
Return value: string
Sets current position within the stream using the seek direction type. Equivalent to the engine's
CTStream::Seek_t().
Arguments:
-
offset- Byte offset from a specific point in the stream to shift the current position by. -
seek_dir- Seek direction type to use from theSEEKenum.
Return value: null
Sets current position within the stream from the beginning of it. Equivalent to the engine's
CTStream::SetPos_t().
Arguments:
-
position- Byte offset from the beginning of the stream to set its current position to.
Return value: null
Returns current position within the stream. Equivalent to the engine's
CTStream::GetPos_t().
Return value: integer
Checks whether the current position is at the very end of the stream (no more bytes that can be read). Equivalent to the engine's
CTStream::AtEOF().
Return value: bool
Returns length of data in bytes. Equivalent to the engine's
CTStream::GetStreamSize().
Return value: integer
Calculates CRC32 hash of the stream data. Equivalent to the engine's
CTFileStream::GetStreamCRC32_t().
Return value: integer
Reads a 32-bit float value and returns it as a Squirrel float value. Equivalent to the engine's
CTStream::operator>>(float).
Return value: float
Reads a 64-bit float value and returns it as a Squirrel float value. Equivalent to the engine's
CTStream::operator>>(double).
Return value: float
Reads an unsigned 8-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(UBYTE).
Return value: integer
Reads an unsigned 16-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(UWORD).
Return value: integer
Reads an unsigned 32-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(ULONG).
Return value: integer
Reads an unsigned 64-bit integer and returns it as a Squirrel integer.
Return value: integer
Reads a signed 8-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(SBYTE).
Return value: integer
Reads a signed 16-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(SWORD).
Return value: integer
Reads a signed 32-bit integer and returns it as a Squirrel integer. Equivalent to the engine's
CTStream::operator>>(SLONG).
Return value: integer
Reads a signed 64-bit integer and returns it as a Squirrel integer.
Return value: integer
Reads a boolean value as a 32-bit integer and returns it as a Squirrel boolean value. Equivalent to the engine's
CTStream::operator>>(BOOL).
Return value: bool
Reads the string length as a 32-bit integer then reads that amount of characters afterwards. Equivalent to the engine's
operator>>(CTStream, CTString).
Return value: string
Reads bytes until it hits a zero or the end of the stream and and returns read data as a string (including the null terminator).
Return value: string
Reads a filename and returns it as a string. Equivalent to the engine's
operator>>(CTStream, CTFileName).
Return value: string
Reads specified amount of bytes in order and return them as a data buffer of that length.
Arguments:
-
bytes- Amount of bytes to read.
Return value: CRawDataBuffer
Reads a string until the specified character. Equivalent to the engine's
CTStream::GetLine_t().
Arguments:
-
separator(optional) - Character code as an integer that acts as the end of a line. Set to a newline character (\n) by default.
Return value: string
Reads a string of the same length as the specified string and checks whether they match, otherwise throws a runtime error. Equivalent to the engine's
CTStream::ExpectKeyword_t().
Arguments:
-
keyword- String with a keyword to expect.
Return value: null
Reads a chunk ID consisting of 4 bytes and checks whether it matches the first 4 characters in the specified string, otherwise throws a runtime error. Equivalent to the engine's
CTStream::ExpectID_t().
Arguments:
-
id- Chunk ID as a string with 4 characters.
Return value: null
Reads a chunk ID consisting of 4 bytes and returns them as a 4-character string without advancing the position (i.e. by going back by 4 bytes). Equivalent to the engine's
CTStream::PeekID_t().
Return value: string
Reads a chunk ID consisting of 4 bytes and returns them as a 4-character string. Equivalent to the engine's
CTStream::GetID_t().
Return value: string
Class for representing a file stream for writing data to disk.
Warning
This class is currently unfinished and is not available for use in Squirrel! If you're looking to serialize custom information for your scripts, use Core.LocalStorage class.
Methods for writing
[!WARNING] These methods are currently unusable and this documentation for them is unfinished!
| Method | Arguments | Return value | Description |
|---|---|---|---|
CreateLocal |
string |
N/A | Creates a new file on disk using the specified path inside Temp/CustomSquirrelData/ relative to the game directory for writing data. Overwrites existing files under the same path. |
WriteFloat |
float |
N/A | Writes a 32-bit float value and advances the current position. Equivalent to the engine's CTStream::operator<<(float). |
WriteDouble |
float |
N/A | Writes a 64-bit float value and advances the current position. Equivalent to the engine's CTStream::operator<<(double). |
WriteU8 |
integer |
N/A | Writes an unsigned 8-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(UBYTE). |
WriteU16 |
integer |
N/A | Writes an unsigned 16-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(UWORD). |
WriteU32 |
integer |
N/A | Writes an unsigned 32-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(ULONG). |
WriteU64 |
integer |
N/A | Writes an unsigned 64-bit integer and advances the current position. |
WriteS8 |
integer |
N/A | Writes a signed 8-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(SBYTE). |
WriteS16 |
integer |
N/A | Writes a signed 16-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(SWORD). |
WriteS32 |
integer |
N/A | Writes a signed 32-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(SLONG). |
WriteS64 |
integer |
N/A | Writes a signed 64-bit integer and advances the current position. |
WriteBool |
bool |
N/A | Writes a boolean value as a 32-bit integer and advances the current position. Equivalent to the engine's CTStream::operator<<(BOOL). |
WriteString |
string |
N/A | Writes string length as a 32-bit integer and then every string character byte by byte (without the null terminator) and advances the current position. Equivalent to the engine's operator<<(CTStream, CTString). |
WriteStringNull |
string |
N/A | Writes every string character byte by byte, including the null terminator at the end and advances the current position. |
WriteFilename |
string |
N/A | Writes a filename and advances the current position. Equivalent to the engine's operator<<(CTStream, CTFileName). |
WriteBuffer |
CRawDataBuffer |
N/A | Writes all bytes from the data buffer in order and advances the current position. |
PutLine |
string |
N/A | Writes the specified string as regular text and appends a line break at the end (\n). Equivalent to the engine's CTStream::PutLine_t(). |
PutString |
string |
N/A | Writes the specified string as regular text. Equivalent to the engine's CTStream::PutString_t(). |
WriteID |
string |
N/A | Writes a chunk ID using the first 4 characters from the specified string and advances the current position. Equivalent to the engine's CTStream::WriteID_t(). |
Designed and developed by Dreamy Cecil since 2022