Repository navigation
Utility Functions
Kakrain edited this page Jul 21, 2026
·
6 revisions
| Function | Description |
|---|---|
GetField(field:string):any |
Returns a value of a specific field |
ToInt(x), ToFloat(x)
|
Type casting to float or to int. |
Min(array), Max(array)
|
gets the maximum or minimum value of an array example: [0,1] it would get 1 if maximum |
RandomFloat():float |
random float between 0.0–1.0 |
RandomBetweenInts(a,b):int |
Random integer between a and b |
ContainsCS(s1:string,s2:string):bool |
is s2 contained in s1? Case-sensitive |
ContainsCI(s1:string,s2:string):bool |
is s2 contained in s1? Case-insensitive |
StartsWith(s1:string,s2:string):bool |
if s1 starts with s2? Case-sensitive |
Count(A:record group):int |
how many records there are in A? |
Clone(A:record group, n:int):record group |
A should have only 1 record, clones this record n times |
CherryPick(A:record group,B:record group,condition):record group |
from the records of A, get same amount of records of B, given that for each B[i], A[i] fullfils its condition with respect to B[i] |
CategorizeGivenField(A:record group,field:string): Array of record group |
return an array of groups of records, categorized in terms of a specific field |
FileExists(filepath:string) |
does this File exists? please use in combination GetRealPath |
GetRealPath(relative_path:string) |
get the real path of the relative path |
GetSkeletonLink(fullpath:string) |
open this mesh file, and searches for the skeleton link |
Any(A:array,f:lambda):bool |
return true if for any A[i] of the array f(A[i]) is true otherwise false |
All(A:array,f:lambda):bool |
return false if for any A[i] of the array f(A[i]) is false otherwise true |
RegexMatch(input:string, pattern:string):bool |
return true if the string matches the regex pattern |
Replace(fullstring:string,search:string,replace:string,optional ignore_case:bool):string |
return the fullstring but with all instances of search replaced by replace, if ignore_case is true, the replacement will be done ignoring case |
ExtractChildrenUntil(A:set, match_condition: bool, stop_condition:bool, optional category:string, optional pruneBranch:bool(default false). optional maxVisits:in, optional getEarly:bool):set |
returns a set of all children given condition, until a specific condition, if pruneBranch is true, once it matches, it stops searching for that branch, getEarly retrieves only the created record, ignores modifications of that record from other mods. |
ChanceOfExtraData(category:string, selector:bool, index:int, optional isPool:bool):float |
returns a chance of specific extra data given the selector, where the chance is in the index (from 0 to 2) and relative to the sum of all ExtraData or all the ExtraData that fullfils isPool |
Intersects(fullpath:string, p1:float[3], p2:float[3], optional fast:bool = false):float |
Checks whether the axis-aligned box defined by the opposite corners p1 and p2 intersects the specified mesh. |
GetIntersectionRatio(fullpath:string, p1:float[3], p2:float[3], optional samples:int = 8):float |
Returns a value between 0 and 1 indicating how much of the box intersects the mesh. |
-
Getting Started
-
Cookbook
-
Patch Language
-
Variable Types
-
Miscellaneous
-
Support