Skip to content

Scripting FileSystem

Dreamy Cecil edited this page Oct 25, 2026 · 1 revision

Constants

  • AOF enum - 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
  • SEEK enum - 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

Classes

CFontData

Class for representing a loaded font file.

Metamethods

CFontData(file)

Constructs a new font by loading it from the specified file.

Arguments:

  • file - Path to the .fnt file to load.

Methods

GetTextureFile()

Returns path to the texture file used by the font. Equivalent to the engine's CFontData::fd_fnTexture.

Return value: string


GetWidth()

Returns maximum width of any character in the font in pixels. Equivalent to the engine's CFontData::GetWidth().

Return value: integer


GetHeight()

Returns maximum height of any character in the font in pixels. Equivalent to the engine's CFontData::GetHeight().

Return value: integer

Variables

pixCharSpacing

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

pixLineSpacing

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

bFixedWidth

Whether the font should be monospace. Equivalent to the engine's CFontData::fd_bFixedWidth.

Type Default value Readable Writeable
bool Font-dependent Yes Yes

CTextureObject

Class for representing a loaded texture.

Metamethods

CTextureObject(file)

Constructs a new texture by loading it from the specified file.

Arguments:

  • file - Path to the .tex file to load.

Methods

NextAnim()

Start next available animation in the list.

Return value: null


PrevAnim()

Start previous available animation in the list.

Return value: null


NextFrame()

Skip to the next frame in the current animation.

Return value: null


PrevFrame()

Revert to the previous frame in the current animation.

Return value: null


FirstFrame()

Reset the current animation to the first frame.

Return value: null


LastFrame()

Reset the current animation to the last frame.

Return value: null


GetCurrentFrame()

Get current frame of the current animation.

Return value: integer


GetInBetweenFrames()

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:

  1. integer - Index of the current frame.
  2. integer - Index of the next frame (may not always be "current + 1").
  3. float - The current progress between the two frames from 0.0 to 1.0.

GetAnimCount()

Get amount of animations in the texture.

Return value: integer


GetAnimInfo(anim)

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:

  1. string - Animation name.
  2. integer - Amount of frames in the animation.
  3. float - Time between each frame in seconds.

GetAnimLength(anim)

Get length of the specified animation in seconds.

Arguments:

  • anim - Index of the animation to check.

Return value: float


GetCurrentAnim()

Get index of the current animation.

Return value: integer


GetCurrentAnimFrames()

Get amount of frames in the current animation.

Return value: integer


GetCurrentAnimLength()

Get length of the current animation in seconds.

Return value: float


SetSpeed(anim, speed)

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 is 0.033333.

Return value: null


PlayAnim(anim, flags)

Start playing a new animation with specific flags.

Arguments:

  • anim - Index of the animation to play.
  • flags - Animation flags from the AOF enum.

Return value: null


SwitchToAnim(anim)

Smoothly switch to a different animation.

Arguments:

  • anim - Index of the animation to switch to.

Return value: null


PauseAnim()

Pause currently playing animation. Sets AOF.PAUSED flag to it.

Return value: null


ContinueAnim()

Continue currently paused animation. Removes AOF.PAUSED flag from it.

Return value: null


IsPaused()

Check whether the current animation is paused.

Return value: bool


IsAnimFinished()

Check whether the current non-looping animation has finished playing.

Return value: bool


SelectFrameInTime(time)

Skip to the specified time in the current animation.

Arguments:

  • time - Time to skip to in seconds.

Return value: null


OffsetPhase(time)

Offset the current animation by a certain amount of seconds.

Arguments:

  • time - Amount of seconds to offset the animation by.

Return value: null


GetPassedTime()

Get time from when the animation started playing in seconds.

Return value: float


GetWidth()

Get texture width in meters.

Return value: float


GetHeight()

Get texture height in meters.

Return value: float


GetPixWidth()

Get texture width in pixels.

Return value: integer


GetPixHeight()

Get texture height in pixels.

Return value: integer


GetFlags()

Get texture flags.

Return value: integer

FileSystem.Reader

Class for representing a file stream for reading data from disk.

Methods

Open(path)

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


Close()

Closes any open file, finishing the writing/reading procedure. Equivalent to the engine's CTFileStream::Close().

Return value: null


IsOpen()

Returns whether the stream is currently open for some file.

Return value: bool


GetDescription()

Returns path of the currently open file. Equivalent to the engine's CTStream::GetDescription().

Return value: string


Seek(offset, seek_dir)

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 the SEEK enum.

Return value: null


SetPos(position)

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


GetPos()

Returns current position within the stream. Equivalent to the engine's CTStream::GetPos_t().

Return value: integer


AtEOF()

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


GetSize()

Returns length of data in bytes. Equivalent to the engine's CTStream::GetStreamSize().

Return value: integer


GetCRC32()

Calculates CRC32 hash of the stream data. Equivalent to the engine's CTFileStream::GetStreamCRC32_t().

Return value: integer


ReadFloat()

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


ReadDouble()

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


ReadU8()

Reads an unsigned 8-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(UBYTE).

Return value: integer


ReadU16()

Reads an unsigned 16-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(UWORD).

Return value: integer


ReadU32()

Reads an unsigned 32-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(ULONG).

Return value: integer


ReadU64()

Reads an unsigned 64-bit integer and returns it as a Squirrel integer.

Return value: integer


ReadS8()

Reads a signed 8-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(SBYTE).

Return value: integer


ReadS16()

Reads a signed 16-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(SWORD).

Return value: integer


ReadS32()

Reads a signed 32-bit integer and returns it as a Squirrel integer. Equivalent to the engine's CTStream::operator>>(SLONG).

Return value: integer


ReadS64()

Reads a signed 64-bit integer and returns it as a Squirrel integer.

Return value: integer


ReadBool()

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


ReadString()

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


ReadStringNull()

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


ReadFilename()

Reads a filename and returns it as a string. Equivalent to the engine's operator>>(CTStream, CTFileName).

Return value: string


ReadBuffer(bytes)

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


GetLine(separator = '\n')

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


ExpectKeyword(keyword)

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


ExpectID(id)

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


PeekID()

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


GetID()

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

FileSystem.Writer (unfinished)

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

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().

Clone this wiki locally