# Misc Misc functions and methods that don't really fit in a single place at the moment - - - ## Level2XP ```pascal function Level2XP(level: Integer): Integer; ``` Converts a level to the xp required for that level. Example: ```pascal WriteLn Level2XP(70); ``` - - - ## XP2Level ```pascal function XP2Level(xp: Integer): Integer; ``` Converts XP to the respective level. Example: ```pascal WriteLn XP2Level(100000); ``` - - - ## FormatNumber ```pascal function FormatNumber(n: Double; dec: Byte = 3): String; ``` Truncates a number with a runescape like truncation. Example: ```pascal WriteLn FormatNumber(100000); //100k ``` - - - ## TColor.Random ```pascal function TColor.Random(min: Byte = $80): TColor; static; ``` Returns a random `TColor` with a `min` value of brightness. `min` is a `Byte` so it goes from $00 (0) to $FF (255). Example: ```pascal WriteLn TColor.Random(); ``` - - - ## TColorArray.GetRarest ```pascal function TColorArray.GetRarest(): TColor; ``` Returns a the rarest `TColor` in the `TColorArray`. Example: ```pascal WriteLn arr.GetRarest(); ``` - - - ## TStringArray.AnyContains ```pascal function TStringArray.AnyContains(value: String; caseSensitive: Boolean = True): Boolean; ``` Returns True/False if any String in the TStringArray contains `value`. - - - ## Activity Global `Activity` variable. You can use this to handle the activity in your script. The idea behind "Activity" is that it's a timer, by default that runs for 5 minutes. Everytime your script is considered "active" the timer is reset back to the start. If `Activity.IsFinished` ever returns `True` that means your script is inactive or you are not restarting `Activity` properly. By default, WaspLib will restart `Activity` for your when {ref}`XPBar.EarnedXP` or {ref}`XPBar.WaitXP` return `True`. For more custom ways of using this kind of activity tracker you need to implement it but you could for example, in a fishing script, restart `Activity` whenever you get a fish with: ```pascal Activity.Restart(); ``` Using `Activity` to shutdown your script or correct course is up to you. A simple way to shutdown your script would be to add this to your main loop: ```pascal if Activity.IsFinished then raise 'Script shutdown due to no activity detected for 5 minutes.'; ```