Repository navigation
Scripting Core
-
Seasonenum - Contains types of possible seasonal events:-
Season.None- No season -
Season.Valentine- Valentine's Day week -
Season.Birthday- Serious Sam anniversary week -
Season.Halloween- Halloween month -
Season.Christmas- Christmas & New Year holidays -
Season.Anniversary- Classics Patch anniversary week -
Season.Max- Maximum amount of seasons
-
-
TestTypeenum - Contains types of testing that a ray can perform when hitting models:-
TestType.NONE- Ignores models altogether -
TestType.SIMPLE- Tests whether a ray passes through a sphere that approximately covers an entire model -
TestType.COLLISIONBOX- Tests whether a ray passes through the current collision box of a specific model -
TestType.FULL- Tests whether a ray hits any of the model triangles -
TestType.FULLSEETHROUGH- Tests whether a ray hits any of the model triangles but ignoring entities marked with anENF_SEETHROUGHflag
-
-
LineMaskenum - Pre-defined pattern types (bit masks) for rendering lines on drawports:-
LineMask.Full- Full line -
LineMask.Symmetric_16- 16-pixel long dash-dot pattern -
LineMask.Symmetric_32- 32-pixel long dash-dot pattern -
LineMask.Point- Dotted line -
LineMask.Dot_2- 2-pixel long dashed line -
LineMask.Dot_4- 4-pixel long dashed line -
LineMask.Dot_8- 8-pixel long dashed line -
LineMask.Dot_16- 16-pixel long dashed line -
LineMask.Pattern_3_1- 3-pixel long line with 1-pixel long spacing -
LineMask.Pattern_6_2- 6-pixel long line with 2-pixel long spacing -
LineMask.Pattern_12_4- 12-pixel long line with 4-pixel long spacing -
LineMask.Pattern_1_3- 1-pixel long line with 3-pixel long spacing -
LineMask.Pattern_2_6- 2-pixel long line with 6-pixel long spacing -
LineMask.Pattern_4_12- 4-pixel long line with 12-pixel long spacing
-
Class for representing a polygon of some brush within the current world.
Sets up a new pointer to a brush polygon.
Arguments:
-
other(optional) - AnotherCBrushPolygonto reference with this instance.
Compares this brush polygon pointer with another brush polygon pointer (or
null). A helper method for the lack of the==operator overloading.
Arguments:
-
other- AnotherCBrushPolygonto compare this one with.
Return value: bool
Returns plane of the brush polygon. Equivalent to the engine's
CBrushPolygon::bpo_pbplPlane->bpl_plAbsolute.
Return value: FLOATplane3D
Returns surface type of the brush polygon. Equivalent to the engine's
CBrushPolygon::bpo_bppProperties.bpp_ubSurfaceType.
Return value: integer
Returns distance from the specified point to the closest edge of the brush polygon. Equivalent to the engine's
CBrushPolygon::GetDistanceFromEdges().
Arguments:
-
point-FLOAT3Dwith the absolute position.
Return value: float
Class for casting physical rays within the current world.
Sets up a ray from a specific entity to shoot from the specified placement until some maximum distance.
Arguments:
-
owner-CEntityPointerwith the entity that's casting the ray (ornull). -
placement-CPlacement3Dwith the placement to shoot the ray from in the direction of the angle. -
max_distance(optional) - Maximum distance that the ray can reach in meters.
Sets up a ray from a specific entity to shoot from the specified point until another point.
Arguments:
-
owner-CEntityPointerwith the entity that's casting the ray (ornull). -
source-FLOAT3Dwith the source point of the ray to shoot from. -
destination-FLOAT3Dwith the destination point of the ray to shoot towards.
Returns origin of the ray pointed in the direction of shooting. Equivalent to the engine's
CCastRay::cl_plRay.
Return value: CPlacement3D
Returns entity that's shooting the ray (may be none). Equivalent to the engine's
CCastRay::cr_penOrigin.
Return value: CEntityPointer
Returns origin point of the ray. Equivalent to the engine's
CCastRay::cr_vOrigin.
Return value: FLOAT3D
Returns target point of the ray. Equivalent to the engine's
CCastRay::cr_vTarget.
Return value: FLOAT3D
Returns the hit entity after casting a ray (may be none). Equivalent to the engine's
CCastRay::cr_penHit.
Return value: CEntityPointer
Returns the hit point after casting a ray. Equivalent to the engine's
CCastRay::cr_vHit.
Return value: FLOAT3D
Returns distance between the ray origin and the hit point after casting a ray. Equivalent to the engine's
CCastRay::cr_fHitDistance.
Return value: float
Returns hit brush polygon after casting a ray (may be null). Equivalent to the engine's
CCastRay::cr_pbpoBrushPolygon.
Return value: CBrushPolygon
Casts a ray for the first time within the currenly running world. Equivalent to the engine's
CCastRay::Cast().
Return value: null
Casts a ray again from the last hit point within the currenly running world. Equivalent to the engine's
CCastRay::ContinueCast().
Return value: null
Whether the ray should hit brush polygons marked with the "Portal" flag. Equivalent to the engine's
CCastRay::cr_bHitPortals.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
false |
Yes | Yes |
Whether the ray should hit brush polygons marked that are both visible and can be seen through. Equivalent to the engine's
CCastRay::cr_bHitTranslucentPortals.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
true |
Yes | Yes |
Whether the ray should hit invisible field brushes (e.g.
TouchFieldentities). Equivalent to the engine'sCCastRay::cr_bHitFields.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
false |
Yes | Yes |
Whether the ray should hit brushes at all. Equivalent to the engine's
CCastRay::cr_bHitBrushes.
Important
This variable is only available starting with The Second Encounter v1.07!
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
true |
Yes | Yes |
Whether the ray should hit invisible terrain polygons. Equivalent to the engine's
CCastRay::cr_bHitTerrainInvisibleTris.
Important
This variable is only available starting with The Second Encounter v1.07!
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
false |
Yes | Yes |
Whether the ray is "physical", i.e. can pass where bullets can pass, like brush polygons marked with the "Shoot through" flag. Equivalent to the engine's
CCastRay::cr_bPhysical.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
bool |
false |
Yes | Yes |
Radius of the ray. Equivalent to the engine's
CCastRay::cr_fTestR.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
float |
0 (infinitely thin) |
Yes | Yes |
Type of testing to perform when hitting models. Equivalent to the engine's
CCastRay::cr_ttHitModels.
| Type | Default value | Readable | Writeable |
|---|---|---|---|
integer |
TestType.SIMPLE |
Yes | Yes |
Class for representing a drawable surface on screen.
Compares this draw port pointer with another draw port pointer. A helper method for the lack of the
==operator overloading.
Arguments:
-
other- AnotherCDrawPortto compare this one with.
Return value: bool
Checks whether the drawport is in dual-head mode (has a resolution in 8:3 aspect ratio).
Return value: bool
Checks whether the drawport was created as a "widescreen" one.
Return value: bool
Returns width of the drawport in pixels.
Return value: integer
Returns height of the drawport in pixels.
Return value: integer
Sets a new font for all text that will be drawn later and resets all font settings below to defaults.
Arguments:
-
font-CFontDatawith the new font to set.
Return value: null
Sets new spacing between each character in pixels.
Arguments:
-
spacing- Amount of pixels to set between each text character.
Return value: null
Sets new spacing between each line in pixels.
Arguments:
-
spacing- Amount of pixels to set between each text line.
Return value: null
Sets new scale factor for text.
Arguments:
-
scaling- Text scaling factor to set.
Return value: null
Stretches text horizontally based on the specified factor.
Arguments:
-
aspect- Horizontal text scaling factor to set.
Return value: null
Changes text output mode:
-1- prints decorations as normal text0- ignores all decorations1- parses and applies all decorations
Arguments:
-
mode- Text mode to set.
Return value: null
Calculates width of the specified text in pixels based on the last font setup.
Arguments:
-
text- String to calculate the width of.
Return value: integer
Draws text of the specified color at the specified coordinates aligned to top left.
Tip
Using color tags such as ^c and ^a in text can override the specified default color.
Arguments:
-
text- String to draw on screen. -
x- Horizontal position to draw the text from in pixels. -
y- Vertical position to draw the text from in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Draws text of the specified color at the specified coordinates aligned to top center.
Tip
Using color tags such as ^c and ^a in text can override the specified default color.
Arguments:
-
text- String to draw on screen. -
x- Horizontal position to draw the text from in pixels. -
y- Vertical position to draw the text from in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Draws text of the specified color at the specified coordinates aligned to middle center.
Tip
Using color tags such as ^c and ^a in text can override the specified default color.
Arguments:
-
text- String to draw on screen. -
x- Horizontal position to draw the text from in pixels. -
y- Vertical position to draw the text from in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Draws text of the specified color at the specified coordinates aligned to top right.
Tip
Using color tags such as ^c and ^a in text can override the specified default color.
Arguments:
-
text- String to draw on screen. -
x- Horizontal position to draw the text from in pixels. -
y- Vertical position to draw the text from in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Returns position of the last character of a string that fits in the specified width of pixels from the first argument.
Arguments:
-
max_width- Maximum width in pixels that the text should fit in. -
text- String to fit within maximum width.
Return value: integer
Formats the string to fit it in the specified width of pixels from the first argument by inserting line breaks after full words at right places.
Arguments:
-
max_width- Maximum width in pixels to fit the text in. -
text- String to format to fit within maximum width.
Return value: string
Draws specified texture on the drawport as a rectangle with two points specified as arrays of X,Y coordinates and tinted using either one color for the entire texture or an array of four colors per each corner of the texture.
Arguments:
-
texture-CTextureObjectwith the texture to draw. -
xy0- Array with the X,Y coordinates of the top left corner in pixels, e.g.[0, 0]. -
xy1- Array with the X,Y coordinates of the bottom right corner in pixels, e.g.[20, 20]. -
colors-integervalue with the color for the entire texture ORarraywith fourintegervalues with the colors for each corner. All in the 32-bit RGBA format.
Return value: null
Draws specified texture on the drawport as a rectangle with two points specified as arrays of X,Y coordinates and two arrays of UV map coordinates for drawing a part of the texture. The last argument is for tinting the texture using either one color for the entire texture or an array of four colors per each corner of the texture.
Arguments:
-
texture-CTextureObjectwith the texture to draw. -
xy0- Array with the X,Y coordinates of the top left corner in pixels, e.g.[0, 0]. -
uv0- Array with the U,V coordinates of the top left corner from0.0to1.0, e.g.[0, 0.2]. -
xy1- Array with the X,Y coordinates of the bottom right corner in pixels, e.g.[20, 20]. -
uv1- Array with the U,V coordinates of the bottom right corner from0.0to1.0, e.g.[0.8, 1]. -
colors-integervalue with the color for the entire texture ORarraywith fourintegervalues with the colors for each corner. All in the 32-bit RGBA format.
Return value: null
Sets a new texture to be used when drawing shapes with
AddTexture*functions. Needs to be reset usingFlushRenderingQueue()after all drawing is done.
Arguments:
-
texture-CTextureObjectwith the current texture to set. -
clamp- Whether to clamp the edges of the texture instead of repeating it when using UV map values past the0.0-1.0boundaries. Recommended to disable for tiled textures.
Return value: null
Draws texture from the last
InitTexture()call on the drawport as a rectangle with two points specified as arrays of X,Y coordinates and tinted using either one color for the entire texture or an array of four colors per each corner of the texture.
Arguments:
-
xy0- Array with the X,Y coordinates of the top left corner in pixels, e.g.[0, 0]. -
xy1- Array with the X,Y coordinates of the bottom right corner in pixels, e.g.[20, 20]. -
colors-integervalue with the color for the entire texture ORarraywith fourintegervalues with the colors for each corner. All in the 32-bit RGBA format.
Return value: null
Draws texture from the last
InitTexture()call on the drawport as a rectangle with two points specified as arrays of X,Y coordinates and two arrays of UV map coordinates for drawing a part of the texture. The last argument is for tinting the texture using either one color for the entire texture or an array of four colors per each corner of the texture.
Arguments:
-
xy0- Array with the X,Y coordinates of the top left corner in pixels, e.g.[0, 0]. -
uv0- Array with the U,V coordinates of the top left corner from0.0to1.0, e.g.[0, 0.2]. -
xy1- Array with the X,Y coordinates of the bottom right corner in pixels, e.g.[20, 20]. -
uv1- Array with the U,V coordinates of the bottom right corner from0.0to1.0, e.g.[0.8, 1]. -
colors-integervalue with the color for the entire texture ORarraywith fourintegervalues with the colors for each corner. All in the 32-bit RGBA format.
Return value: null
Draws texture from the last
InitTexture()call on the drawport using 4 arbitrary X,Y points paired with UV map coordinates.
Arguments:
-
xy0- Array with the X,Y coordinates of the first point in pixels, e.g.[0, 0]. -
uv0- Array with the UV coordinates of the first point from0.0to1.0, e.g.[0, 0.2]. -
xy1- Array with the X,Y coordinates of the second point in pixels, e.g.[20, 0]. -
uv1- Array with the UV coordinates of the second point from0.0to1.0, e.g.[0.8, 0.2]. -
xy2- Array with the X,Y coordinates of the third point in pixels, e.g.[20, 40]. -
uv2- Array with the UV coordinates of the third point from0.0to1.0, e.g.[0.8, 1]. -
xy3- Array with the X,Y coordinates of the fourth point in pixels, e.g.[0, 40]. -
uv3- Array with the UV coordinates of the fourth point from0.0to1.0, e.g.[0, 1]. -
color0- Integer with the color value in the 32-bit RGBA format for the first point. -
color1- Integer with the color value in the 32-bit RGBA format for the second point. -
color2- Integer with the color value in the 32-bit RGBA format for the third point. -
color3- Integer with the color value in the 32-bit RGBA format for the fourth point.
Return value: null
Wraps up rendering of some texture after setting it up with
InitTexture().
Return value: null
Draws a point at the specified X,Y coordinate of the specified radius and color.
Important
This function is only available starting from The Second Encounter v1.07!
Arguments:
-
x- X position of the point in pixels. -
y- Y position of the point in pixels. -
radius- Radius of a centered square point in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Draws a line from point X0,Y0 to point X1,Y1 of the specified color with an optional line mask.
Arguments:
-
x0- Starting X position of the line in pixels. -
y0- Starting Y position of the line in pixels. -
x1- Ending X position of the line in pixels. -
y1- Ending Y position of the line in pixels. -
color- Integer with the color value in the 32-bit RGBA format. -
line_mask(optional) - Line pattern as a bit mask of pixels. A few default patterns are specified in theLineMaskenum.
Return value: null
Draws a rectangle from the top left corner (X0,Y0) to the bottom right corner (X1,Y1) of the specified color with an optional line mask.
Arguments:
-
x0- Position of the left edge of the border in pixels. -
y0- Position of the top edge of the border in pixels. -
x1- Position of the right edge of the border in pixels. -
y1- Position of the bottom edge of the border in pixels. -
color- Integer with the color value in the 32-bit RGBA format. -
line_mask(optional) - Line pattern as a bit mask of pixels. A few default patterns are specified in theLineMaskenum.
Return value: null
Fills a section of the drawport from the top left corner (X0,Y0) to the bottom right corner (X1,Y1) of the specified color.
Arguments:
-
x0- Position of the left edge of the rectangle in pixels. -
y0- Position of the top edge of the rectangle in pixels. -
x1- Position of the right edge of the rectangle in pixels. -
y1- Position of the bottom edge of the rectangle in pixels. -
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Fills a section of the drawport from the top left corner (X0,Y0) to the bottom right corner (X1,Y1) with a gradient of colors for each corner.
Arguments:
-
x0- Position of the left edge of the rectangle in pixels. -
y0- Position of the top edge of the rectangle in pixels. -
x1- Position of the right edge of the rectangle in pixels. -
y1- Position of the bottom edge of the rectangle in pixels. -
color_tl- Integer with the color value in the 32-bit RGBA format for the top left corner. -
color_tr- Integer with the color value in the 32-bit RGBA format for the top right corner. -
color_bl- Integer with the color value in the 32-bit RGBA format for the bottom left corner. -
color_br- Integer with the color value in the 32-bit RGBA format for the bottom right corner.
Return value: null
Fills the entire screen with the specified color.
Arguments:
-
color- Integer with the color value in the 32-bit RGBA format.
Return value: null
Class for representing a container of raw bytes.
Sets up a new data buffer of the specified length in bytes. All bytes are set to 0 by default.
Arguments:
-
bytes- Amount of bytes that the buffer should contain.
Returns an array of byte values formatted as
%02Xwithin[]separated by spaces, e.g.[01 22 3A FF].
Return value: string
Compares contents of this data buffer with another data buffer. A helper method for the lack of the
==operator overloading.
Arguments:
-
other- AnotherCRawDataBufferto compare this one with.
Return value: bool
Returns length of the data buffer in bytes.
Return value: integer
Resets all bytes in the data buffer to 0.
Sets the specified integer value in the buffer starting from the specified offset.
Throws a runtime error if the data doesn't fit within the bounds of the buffer.
Arguments:
-
offset- Starting position in the buffer to write the value to. -
value- Integer value that will be truncated to a single byte.
Sets the specified boolean value in the buffer starting from the specified offset.
Throws a runtime error if the data doesn't fit within the bounds of the buffer.
Arguments:
-
offset- Starting position in the buffer to write the value to. -
value- Boolean value that will be written as a 32-bit integer (occupying the next 4 bytes).
Sets the specified integer value in the buffer starting from the specified offset.
Throws a runtime error if the data doesn't fit within the bounds of the buffer.
Arguments:
-
offset- Starting position in the buffer to write the value to. -
value- Integer value that will be written as a 32-bit integer (occupying the next 4 bytes).
Sets the specified float value in the buffer starting from the specified offset.
Throws a runtime error if the data doesn't fit within the bounds of the buffer.
Arguments:
-
offset- Starting position in the buffer to write the value to. -
value- Float value that will be written as a single-precision float (occupying the next 4 bytes).
Copies all characters from the specified string byte-by-byte in the buffer starting from the specified offset. Doesn't include the null terminator at the end. Example:
"Hello"will write 5 bytes.
Throws a runtime error if the data doesn't fit within the bounds of the buffer.
Arguments:
-
offset- Starting position in the buffer to write the value to. -
value- String value that will be written byte-by-byte.
Retrieves a byte value from the specified offset in the buffer and converts it to a 64-bit integer.
Arguments:
-
offset- Starting position in the buffer to read the value from.
Return value: integer
Retrieves a 32-bit boolean value (4 bytes) from the specified offset in the buffer and converts it to either
trueorfalse.
Arguments:
-
offset- Starting position in the buffer to read the value from.
Return value: bool
Retrieves a 32-bit integer value (4 bytes) from the specified offset in the buffer and converts it to a 64-bit integer.
Arguments:
-
offset- Starting position in the buffer to read the value from.
Return value: integer
Retrieves a 32-bit float value (4 bytes) from the specified offset in the buffer.
Arguments:
-
offset- Starting position in the buffer to read the value from.
Return value: float
Retrieves specified amount of bytes starting from the specified offset and constructs a string with each byte as a character in order. Automatically appends a null terminator at the end.
Arguments:
-
offset- Starting position in the buffer to read the value from. -
characters- Amount of bytes to read as string characters (excluding the null terminator), e.g.5for"Hello".
Return value: string
Class for serializing custom data from scripts in JSON format.
Important
Each method of the local storage class takes a directory-like path to the keys. Each time a / character is encountered, it enters an object with the name prior to it and keeps doing it until the last key, which is supposed to contain the respective value.
Example: "container/inner/my data" key name will resolve to a "my data" key inside "inner" object inside another "container" object inside local storage. Whereas "custom data" key name will resolve to a simple "custom data" key inside local storage.
Loads local storage under the specified name or creates a new one if it doesn't exist yet.
Warning
All local storage configs are shared between any and all scripts. Make sure not to use generic local storage names or the names used by other scripts for serializing their data in order to avoid collision or potential loss of data from other scripts.
Arguments:
-
name- Name of a local storage to use.
Caution
Local storage names only support alphanumeric characters (0-9, a-z, A-Z), spaces and underscores (_)! Unsupported characters are replaced with underscores, which may lead to collisions with other storages!
Example: my_data, my@data, my.data and my/data will all utilize the exact same local storage (my_data).
Returns a string with the current contents of the entire storage as a formatted JSON.
Return value: string
Saves modified contents of local storage to disk. Any subsequent creation of local storage with the same name will access newly saved contents.
Return value: null
Clears all contents of local storage, resulting in an empty JSON object.
Return value: null
Checks whether the specified key exists in local storage.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Deletes the specified key from local storage, if it exists.
Note
This method only deletes the last key in the path. To delete all data under a specific object, end the path at the key name of that object instead of each individual key inside of it.
Arguments:
-
path- Key name as a directory-like path.
Return value: null
Checks whether the specified key has a boolean value and it's equal to
false.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a boolean value and it's equal to
true.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a boolean value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a null value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a number value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a string value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has an array value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has an object value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a vector value, i.e. a JSON value that has the exact syntax of
[ number, number, number ].
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a plane value, i.e. a JSON value that has the exact syntax of
[ [ number, number, number ], number ].
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a matrix value, i.e. a JSON value that has the exact syntax of
[ number, number, number, number, number, number, number, number, number ].
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has an axis-aligned bounding box value, i.e. a JSON value that has the exact syntax of
[ number, number, number, number, number, number ].
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Checks whether the specified key has a placement value, i.e. a JSON value that has the exact syntax of
[ [ number, number, number ], [ number, number, number ] ].
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Sets boolean value to the specified key, overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-boolvalue to set.
Return value: null
Sets null value to the specified key, overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path.
Return value: null
Sets number value to the specified key, overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-integerorfloatvalue to set.
Return value: null
Sets string value to the specified key, overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-stringvalue to set.
Return value: null
Sets array value to the specified key, recursively copying all contents from it and overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-arrayvalue to set.
Return value: null
Sets object value to the specified key, recursively copying all contents from it and overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-tablevalue to set.
Return value: null
Sets vector value to the specified key as an array of 3 numbers (X, Y, Z; e.g.
[1, 2, 3]), overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-FLOAT3Dvalue to set.
Return value: null
Sets plane value to the specified key as an array of an array and a number (Normal, Distance; e.g.
[ [0, 1, 0], 4]), overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-FLOATplane3Dvalue to set.
Return value: null
Sets matrix value to the specified key as an array of 9 numbers (e.g.
[1, 0, 0, 0, 1, 0, 0, 0, 1]), overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-FLOATmatrix3Dvalue to set.
Return value: null
Sets axis-aligned bounding box value to the specified key as an array of 6 numbers (X0, Y0, Z0, X1, Y1, Z1; e.g.
[-1, -2, -3, 10, 20, 30]), overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-FLOATaabbox3Dvalue to set.
Return value: null
Sets placement value to the specified key as an array of 2 arrays of 3 numbers (Position, Rotation; e.g.
[[1, 2, 3], [90, 45, 180]]), overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value-CPlacement3Dvalue to set.
Return value: null
Sets any supported value to the specified key, overwriting existing data if there's any.
Throws a runtime error if it fails to set the value.
Arguments:
-
path- Key name as a directory-like path. -
value- Value to set that may only be one of the following types:-
bool,null,integer,float,string,array,table,FLOAT3D,FLOATplane3D,FLOATmatrix3D,FLOATaabbox3D,CPlacement3D
-
Return value: null
Retrieves a boolean value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a boolean value.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool
Retrieves a null value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a null value.
Arguments:
-
path- Key name as a directory-like path.
Return value: null
Retrieves a number value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a number value.
Arguments:
-
path- Key name as a directory-like path.
Return value: float
Retrieves a string value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a string value.
Arguments:
-
path- Key name as a directory-like path.
Return value: string
Retrieves an array value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain an array value.
Arguments:
-
path- Key name as a directory-like path.
Return value: array
Retrieves an object value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain an object value.
Arguments:
-
path- Key name as a directory-like path.
Return value: table
Retrieves a vector value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a vector value (seeIsVectorfunction for valid values).
Arguments:
-
path- Key name as a directory-like path.
Return value: FLOAT3D
Retrieves a plane value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a plane value (seeIsPlanefunction for valid values).
Arguments:
-
path- Key name as a directory-like path.
Return value: FLOATplane3D
Retrieves a matrix value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a matrix value (seeIsMatrixfunction for valid values).
Arguments:
-
path- Key name as a directory-like path.
Return value: FLOATmatrix3D
Retrieves an axis-aligned bounding box value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain an AABB value (seeIsAABBfunction for valid values).
Arguments:
-
path- Key name as a directory-like path.
Return value: FLOATaabbox3D
Retrieves a placement value from the specified key.
Throws a runtime error if the key doesn't exist or doesn't contain a placement value (seeIsPlacementfunction for valid values).
Arguments:
-
path- Key name as a directory-like path.
Return value: CPlacement3D
Retrieves any value from the specified key.
Throws a runtime error if the key doesn't exist or contains a value of an unsupported type.
Note
This function does not distinguish between custom types (such as FLOAT3D) and regular JSON values that they are encoded as, resulting in the latter return value instead.
Arguments:
-
path- Key name as a directory-like path.
Return value: bool/null/float/string/array/table depending on the held value.
Retrieves a boolean value from the specified key.
If the key doesn't exist or doesn't contain a boolean value, returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: bool
Retrieves a number value from the specified key.
If the key doesn't exist or doesn't contain a number value, returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: float
Retrieves a string value from the specified key.
If the key doesn't exist or doesn't contain a string value, returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: string
Retrieves an array value from the specified key.
If the key doesn't exist or doesn't contain an array value, returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: array
Retrieves an object value from the specified key.
If the key doesn't exist or doesn't contain an object value, returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: table
Retrieves a vector value from the specified key.
If the key doesn't exist or doesn't contain a vector value (seeIsVectorfunction for valid values), returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: FLOAT3D
Retrieves a plane value from the specified key.
If the key doesn't exist or doesn't contain a plane value (seeIsPlanefunction for valid values), returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: FLOATplane3D
Retrieves a matrix value from the specified key.
If the key doesn't exist or doesn't contain a matrix value (seeIsMatrixfunction for valid values), returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: FLOATmatrix3D
Retrieves an axis-aligned bounding box value from the specified key.
If the key doesn't exist or doesn't contain an AABB value (seeIsAABBfunction for valid values), returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: FLOATaabbox3D
Retrieves a placement value from the specified key.
If the key doesn't exist or doesn't contain a placement value (seeIsPlacementfunction for valid values), returns the provided default value instead of throwing an error.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: CPlacement3D
Retrieves any value from the specified key.
If the key doesn't exist or contains a value of an unsupported type, returns the provided default value instead of throwing an error.
Note
This function does not distinguish between custom types (such as FLOAT3D) and regular JSON values that they are encoded as, resulting in the latter return value instead.
Arguments:
-
path- Key name as a directory-like path. -
default_value- Default value that will be returned on failure.
Return value: bool/null/float/string/array/table depending on the held value.
Return value: bool with whether the script is running on 1.05 version of Serious Engine 1.
Return value: bool with whether the script is running on 1.07 version of Serious Engine 1.
Return value: bool with whether the script is being run from The First Encounter game.
Return value: bool with whether the script is being run from The Second Encounter game.
Returns an array of version numbers: release, update, patch. For example, version "1.2.3" would return
[1, 2, 3].
Return value: array of integer values with the current version of the patch.
It may omit the patch version number if it's set to 0 (e.g.
1.10if the version numbers are1.10.0) and it may append a special development suffix to it, depending on the build (e.g.1.10-pre1).
Return value: string with the formatted version of Classics Patch.
Consistent across all running instances of the game on the same computer, depending on the time they've been started.
Return value: Timer.Value with the precise CPU timestamp of when Classics Patch was initialized.
Return value: bool with whether the script is running from a game client.
Return value: bool with whether the script is running from a dedicated server application.
Return value: bool with whether the script is running from Serious Editor.
Return value: bool with whether the script is running from a modeler application, e.g. Serious Modeler or Serious SKA Studio.
Return value: integer with the current seasonal event, represented by the Season enum.
Return value: bool with whether Classics Patch is currently running with its own custom mod over vanilla functionality.
Return value: bool with whether the current used Entities library (e.g. EntitiesMP.dll) is from the currently active mod and not from the base game.
This function keeps track of the current script depth and will throw a runtime error if nested scripts go deeper than 16 to avoid a potential stack overflow error.
Arguments:
-
path_string- Path to another script file to include and evaluate at runtime.
Return value: Return value from the specified script or null if nothing is returned.
This function does not keep track of the current script depth and may lead to a stack overflow error, if used improperly.
Arguments:
-
path_string- Path to another script file to compile at runtime.
Return value: function with the compiled script for executing at any point.
Returns the amount of printed characters in a string. Equivalent to the engine's
CTString::Length()function.
Arguments:
-
string- String to count the characters in.
Return value: integer with the amount of characters in a string.
Returns the amount of printed characters in a string, skipping any decorations (e.g. color tags). Equivalent to the engine's
CTString::LengthNaked()function.
Arguments:
-
string- String to count the characters in.
Return value: integer with the amount of undecorated characters in a string.
Strips all decorations (e.g. color tags) from the specified string. Equivalent to the engine's
CTString::Undecorated()function.
Arguments:
-
string- String to undecorate.
Return value: string
Finds the position of the first occurrence of the specified substring in a string. Equivalent to the engine's
CTString::FindSubstr()function.
Arguments:
-
string- String to go through. -
sub- Substring to search for.
Return value: integer of the position with the first occurrence of the substring (-1 if not found).
Replaces all occurrences of a certain substring with a new substring.
Arguments:
-
string- String to go through. -
oldsub- Old substring to replace. -
newsub- String to replace the old substring with.
Return value: string with every old substring replaced with a new substring.
Checks whether a string starts with the specified prefix. Equivalent to the engine's
CTString::HasPrefix()function.
Arguments:
-
string- String to go through. -
prefix- Prefix to check for.
Return value: bool with whether the string starts with the specified prefix.
Removes a prefix from the specified string if it starts with it. Equivalent to the engine's
CTString::RemovePrefix()function.
Arguments:
-
string- String to go through. -
prefix- Prefix to check for and remove.
Return value: string of the specified string without the prefix in the beginning, if it was removed.
Trims the specified string from the left side to a certain amount of characters. Equivalent to the engine's
CTString::TrimLeft()function.
Arguments:
-
string- String to trim. -
characters- Amount of characters to trim the string to.
Return value: array that contains a string with the resulting trimmed string and an integer with the amount of characters that have been trimmed.
Trims the specified string from the right side to a certain amount of characters. Equivalent to the engine's
CTString::TrimRight()function.
Arguments:
-
string- String to trim. -
characters- Amount of characters to trim the string to.
Return value: array that contains a string with the resulting trimmed string and an integer with the amount of characters that have been trimmed.
Removes all leading spaces the specified string from the left side. Equivalent to the engine's
CTString::TrimSpacesLeft()function.
Arguments:
-
string- String to trim.
Return value: array that contains a string with the resulting trimmed string and an integer with the amount of spaces that have been trimmed.
Removes all trailing spaces the specified string from the right side. Equivalent to the engine's
CTString::TrimSpacesRight()function.
Arguments:
-
string- String to trim.
Return value: array that contains a string with the resulting trimmed string and an integer with the amount of spaces that have been trimmed.
Calculates a unique hash value based on string contents. Equivalent to the engine's
CTString::GetHash()function.
Arguments:
-
string- String to hash.
Return value: integer with a 32-bit hash value.
Erases everything from the specified string after the first occurrence of a line break, otherwise leaves it as is. Equivalent to the engine's
CTString::OnlyFirstLine()function.
Arguments:
-
string- String to process.
Return value: string with only the first line of the specified string.
Matches the specified string with a case-insensitive pattern with wildcards.
*symbol matches any 0+ characters and?matches any one character.
Arguments:
-
string- String to check. -
pattern- String pattern to match the string to.
Return value: bool with whether the string matches the specified pattern.
Splits the specified string into two parts at the
poscharacter. Equivalent to the engine'sCTString::Split()function.
Arguments:
-
string- String to split. -
pos- Position of the split.
Return value: array with two string values: left part from position 0 up to pos - 1; right part from position pos up to the string length.
Inserts a new character at the specified position in the string. Equivalent to the engine's
CTString::InsertChar()function.
Arguments:
-
string- String to insert the character into. -
pos- Position for insertion. -
char- Character code to insert (asinteger, notstring).
Return value: string with the newly inserted character.
Deletes a character from the middle of the string. Equivalent to the engine's
CTString::DeleteChar()function.
Arguments:
-
string- String to delete the character from. -
pos- Position for deletion.
Return value: string with the specified character deleted.
Loads contents of a file as a string. Equivalent to the engine's
CTString::Load_t()function.
Arguments:
-
path- Path to the text file to load the contents of.
Return value: string with the contents of the text file.
Saves contents of the string into a text file. Equivalent to the engine's
CTString::Save_t()function.
Arguments:
-
string- String to save into a file. -
path- Path to the text file to save the string into.
Return value: null
Replaces all occurrences of the old character with the new one (both as
integer, notstring).
Arguments:
-
string- String to replace characters in. -
oldchar- Character code to replace. -
newchar- Character code to replace the old ones with.
Return value: string with all old characters replaced with new ones.
Finds the first occurrence of the specified character (as
integer, notstring) from some offset in a string.
Arguments:
-
string- String to go through. -
char- Character code to search for. -
offset- Offset within the string to start searching from (0to search from the beginning).
Return value: integer with the position of the first found character (-1 if not found).
Counts all occurrences of the specified character (as
integer, notstring) from some offset in a string.
Arguments:
-
string- String to go through. -
char- Character code to search for. -
offset- Offset within the string to start searching from (0to search from the beginning).
Return value: integer with the amount of characters in the string.
Extracts a part of a string from the specified offset.
Arguments:
-
string- String to extract from. -
offset- Offset to extract a substring from. -
chars- Amount of characters to extract (-1to extract until the end of the string).
Return value: string with the extracted substring.
Separates the string into parts between a specific character. Example:
StringSeparateByChar("abc|x|y|", '|')->["abc", "x", "y", ""]
Arguments:
-
string- String to go through. -
separator- Character code that separates the string (asinteger).
Return value: array of strings between each separator, excluding the separators themselves.
Separates the string into parts between a specific character. Example:
StringSeparateByString("abc##x##y###", "##")->["abc", "x", "y", "#"]
Arguments:
-
string- String to go through. -
separator- Substring that separates the string (asstring).
Return value: array of strings between each separator, excluding the separators themselves.
Gets the actual index of the printed character in a string after all the decorations (e.g. color tags). Example:
StringGetDecoratedChar("^cff0000Hello", 1)->9
Arguments:
-
string- String to go through. -
offset- Offset of the printed character to retrieve the actual position of.
Return value: integer with the actual position of the character in the string.
Goes through every line in the
masksstring and matchesstringuntil it works, as if usingStringMatches().
Arguments:
-
string- String to match. -
masks- List of patterns separated by line breaks to match the string against.
Return value: bool with whether the string matched any pattern in the mask.
Removes all characters after the last found
\character (or everything if none found). Example:dir\\file.ext->dir\\. Equivalent to the engine'sCTFileName::FileDir()function.
Arguments:
-
path- Path string to get the file directory of.
Return value: string with the directory to the specified file.
Removes everything prior to the last found
\character (including it) and everything after the last.character (if found). Example:dir\\file.ext->file. Equivalent to the engine'sCTFileName::FileName()function.
Arguments:
-
path- Path string to get the file name of.
Return value: string with the name of the specified file.
Removes everything prior to the last found
.character (or everything if none found). Example:dir\\file.ext->.ext. Equivalent to the engine'sCTFileName::FileExt()function.
Arguments:
-
path- Path string to get the file extension of.
Return value: string with the file extension of the specified file, inluding the dot.
Removes everything after the last found
.character (if found). Example:dir\\file.ext->dir\\file. Equivalent to the engine'sCTFileName::NoExt()function.
Arguments:
-
path- Path string to remove the file extension from.
Return value: string with the specified path, excluding the file extension at the end.
If the path starts with the absolute path to the root directory of the currently running game, it gets removed, otherwise keeps it. Example:
C:\\SeriousSam\\MyTextures\\Example.tex->MyTextures\\Example.tex. Equivalent to the engine'sCTFileName::RemoveApplicationPath_t()function.
Arguments:
-
path- Path string to remove the application path from.
Return value: string without the preceeding application path, if it started with it.
Designed and developed by Dreamy Cecil since 2022