Variable Functions - SmallSquareStudios/Psych-Engine-Wiki-Extra GitHub Wiki

String Functions

stringStartsWith(str:String, start:string)

Checks to see if a string starts with something. Returns true if it does.

str - The string variable name.

start - The character to check for.

stringEndsWith(str:String, start:string)

Checks to see if a string ends with something. Returns true if it does.

str - The string variable name.

start - The character to check for.

stringSplit(str:String, split:string)

Splits the string onto a table.

str - The string that you want to split. split - The split identifier that you want to use.

Example: Using stringSplit('name', 'a'), will split a string into parts, with the splits happening every time 'a' is detected in the string.

stringTrim(str:String)

Trims the string.

str - The string that you want to trim.

As of 0.7.1h, I couldn't figure out how stringSplit or stringTrim work. So it might not be a real function.

Number functions

getRandomInt(min:Int, max:Int = FlxMath.MAX_VALUE_INT, exclude:String = '')

Returns a random integer between the min and max variables.

min - The minimum it can choose.

max - The maximum it can choose.

exclude - Optional, the numbers the algorithm should exclude.

getRandomFloat(min:Float, max:Float = 1, exclude:String = '')

Returns a random float between the min and max variables.

min - The minimum it can choose.

max - The maximum it can choose.

exclude - Optional, the numbers the algorithm should exclude.

Exclude using a string. For example, '1, 2, 3'.

Bool functions

getRandomBool(chance:Float = 50)

Has a percent chance of returning true or false.

chance - The chance of the boolean returning true. If set to 100, it will always return true.