Uncategorized Functions
Functions without a category made strictly for them.
FlxColor
FlxColor(color:String):Int
Turns a color string/hexadecimal into an Integer value usable in "setProperty" and other functions.
Examples:
- FlxColor('BLUE') - Returns blue color.
- FlxColor('#FFFF0000') - Returns Red color through hexadecimal in ARGB format, notice how it starts with "#".
getColorFromName
getColorFromName(color:String):Int
Identical function and usage to FlxColor.
getColorFromString
getColorFromString(color:String):Int
Identical function and usage to FlxColor.
getColorFromHex
getColorFromHex(color:String):Int
Turns a color hexadecimal into an Integer value usable in "setProperty" and other functions.
This differs from FlxColor because it doesn't accept color names and doesn't require a "#" before the value.
Examples:
- getColorFromHex('7F7F7F') - Returns gray color.
- getColorFromHex('FF0000') - Returns red color.
stringStartsWith
stringStartsWith(str:String, start:String):Bool
Shortcut for StringTools.startsWith in Lua.
- str - String being checked.
- start - String to check if the previous value starts with it.
Examples:
- stringStartsWith('Test', 'Te') - "Test" starts with "Te", returns true.
- stringStartsWith('Test', 'A') - "Test" doesn't start with "A", returns false.
stringEndsWith
stringEndsWith(str:String, end:String):Bool
Shortcut for StringTools.endsWith in Lua.
- str - String being checked.
- end - String to check if the previous value ends with it.
Examples:
- stringEndsWith('Test', 'st') - "Test" ends with "st", returns true.
- stringEndsWith('Test', 'Z') - "Test" doesn't ends with "Z", returns false.
stringSplit
stringSplit(str:String, split:String):Array<String>
Shortcut for String.split in Lua.
- str - String being checked.
- split - String delimiter.
Examples:
- stringSplit('A,B,C,D,E', ',') - Separates the string through commas, returns the following table: {'A', 'B', 'C', 'D', 'E'}
stringTrim
stringTrim(str:String):String
Clears the spaces at the start and end of a string.
Shortcut for StringTools.trim in Lua.
- str - String being checked.
Examples:
- stringSplit(' Hello World! ') - Returns "Hello World!", notice how the space between words did not get removed.
getRandomBool
getRandomBool(?chance:Float = 50):Bool
Randomizer that returns either "true" or "false".
- chance - Ranges from 0 to 100. Defaults to 50%
Examples:
- getRandomBool(75) - 75% chance of being true.
getRandomInt
getRandomInt(min:Int,
?max:Int = FlxMath.MAX_VALUE_INT,
?exclude:String = ''):Int
Randomizer that returns an integer value.
- min - Minimal number to randomize.
- max (Optional) - Max number to randomize.
- exclude (Optional) - Randomization exclusions, separated by commas.
Examples:
- getRandomInt(1, 5) - Chooses a random number between 1 and 5.
- getRandomInt(1, 8, '3, 4') - Chooses a random number between 1 and 8 that aren't 3 or 4.
getRandomFloat
getRandomFloat(min:Float,
?max:Float = 1,
?exclude:String = ''):Float
Randomizer that returns a float value.
- min - Minimal number to randomize.
- max (Optional) - Max number to randomize.
- exclude (Optional) - Randomization exclusions, separated by commas.
Examples:
- getRandomFloat(-45, 45) - Chooses a random number between -45 and 45.
- getRandomFloat(-1.5, 1.5, '0') - Chooses a random number between -1.5 and 1.5 that aren't 0.
debugPrint
debugPrint(text:Dynamic,
?color:String = 'WHITE'):Void
Shows a colorable text at the top left corner of the screen that fades out after 5 seconds, used for quick debugging purposes.
- text - Text to display.
- color (Optional) - Color hexadecimal string or color name.
Examples:
- debugPrint('Hello World!') - Shows "Hello World!" at the top left corner of the screen.
- debugPrint('ERROR MESSAGE: Boo!', 'FF0000') - Shows a red text at the top left corner of the screen.
getModSetting
getModSetting(saveTag:String, ?modName:String = null):Dynamic
Returns the value saved for a Mod Setting from a properly configured "settings.json".
- saveTag - In settings.json, this is the "save" key in your Custom Setting.
- modName (Optional) - Gives access to the Settings of another Mod, set to null to use the Mod this Lua Script is from.
Examples:
- getModSetting('testbool') - Returns the value from "testbool" setting, which is a boolean, returning either true or false.
- getModSetting('testnumber') - Returns the value from "testnumber" setting, which is an integer, returning a number.
- getModSetting('testkey') - Returns the keys from "testkey", which is a table value with Gamepad and Keyboard inputs, check this snippet for using it properly.