-
Notifications
You must be signed in to change notification settings - Fork 7
Session Expressions Reference
-
flagName- Providing a flag name on its own checks if that flag is set, returning 1 if it is, 0 otherwise. -
!flagName- Inverts the logic for checking flags, returning 0 if the flag is set, 1 otherwise. -
#counterName- Reads the value of a Session Counter (integer) instead of a flag. -
@sliderName- Reads a Session Slider (floating-point number).
Session Expressions can operate on many types of values:
-
bool- True/False value, represented as1or0. -
int- 32-bit integer value, e.g.1,-123. -
float- 32-bit floating-point value, e.g.1.312. -
string- UTF-16 text, e.g."hello". -
Vector2- A pair of 2 floats, available via.xand.yfields, e.g.$vec(3, 4) -
Entity- Represents a Celeste Entity object, e.g.$player.
More complex types have fields that can be accessed via obj.field syntax:
-
.len-int- The length (in characters) of the string, e.g."hello".len->5
-
.x-float- The position of the vector on the x-axis, e.g.$vec(3, 4).x->3 -
.y-float- The position of the vector on the y-axis, e.g.$vec(3, 4).y->4 -
.len- The length of the vector, calculated as$sqrt(x*x + y*y). -
.lenSq- The squared length of the vector, calculated asx*x + y*y. Faster to calculate than.len.
-
.x-float- The position of the entity on the x-axis. -
.y-float- The position of the entity on the y-axis. -
.pos-Vector2- The position of the entity. -
.sid-string- The SID (String ID, used in map editors) of the entity, e.g.FrostHelper/IceSpinnerfor Custom Spinners. Can be?if the SID cannot be obtained for the given entity.
All commands start with $, and allow you to get access to various values, not just those coming from the session. Mods can add their own commands.
-
$deathsHere-int- Returns how many times the player has died in this room, resets after a screen transition. -
$deaths-int- Returns how many times the player has died this session. -
$hasGolden-bool- Returns whether the player is carrying a golden berry. 1 if they are, 0 otherwise. -
$restartedFromGolden-bool- Returns 1 if the current session started due to a golden death. -
$coreMode-bool- Returns the current core mode: 0 if not set, 1 if hot, 2 if cold. -
$photosensitive-bool- Returns whether Photosensitive Mode is enabled. 1 if it is, 0 otherwise. -
$allowLightning,$allowScreenFlash,$allowGlitch,$allowDistort,$allowTextHighlight-bool- Checks the corresponding Everest-extended Photosensitive Mode settings. -
$dashes-int- Current player dash count. -
$maxDashes-int- Maximum allowed player dash count. -
$stamina-float- Current player stamina. -
$speed-Vector2- Player's speed. -
$pi-float- The value of Pi. -
$e-float- The value of Euler's Number. -
$dtime-float- The delta time between frames, taking into account Assist Mode options. -
$player-Entity- The current player.
To read vanilla buttons, you may use any of these Commands:
-
$input.esc,$input.pause -
$input.menuLeft,$input.menuRight,$input.menuUp,$input.menuDown -
$input.menuConfirm,$input.menucancel,$input.menujournal $input.quickrestart$input.jump$input.dash$input.grab$input.talk-
$input.crouchDash- Demodash
Modded buttons can be read via $input.mod.modName.buttonName, for example $input.mod.MaxHelpingHand.ShowHints.
By default, these commands return 1 if the button is held, 0 if it isn't. If you wish to check for something else, you can add a suffix to the command:
-
.check- default behavior. -
.pressed- Whether the button just got pressed. -
.released- Whether the button is not held.
For example, $input.grab.pressed checks if the player has just pressed the Grab button.
To read directional inputs, you can use these commands:
-
$input.aim-Vector2- used for dashing. -
$input.feather-Vector2- used for flying in feathers. -
$input.mountainaim-Vector2- used in the overworld.
These values are Vector2's containing floats in the range [-1, 1]. When playing on a controller, these might be non-integer values, but on keyboard, they will always be -1, 0 or 1. Make sure to keep this in mind, and check the sign of the values (using < 0 or > 0) in most cases.
For example $input.aim.y < 0 checks if the player is aiming downwards.
Functions can be called like $func(arg1, arg2, ...):
-
$min(arg1, arg2, ...)-int/float- returns the smallest value from all provided arguments. -
$max(arg1, arg2, ...)-int/float- returns the largest value from all provided arguments. -
$clamp(x, min, max)-int/float- clamps the value ofxso that its betweenminandmax -
$abs(x)-int/float- Returns the absolute value ofx -
$sin(x),$cos(x),$tan(x)-float- Calculates trigonometrical functions,xis assumed to be in radians. (Tip:$pi) -
$pow(x, y)-float- x raised to the power of y -
$pow2(x)-float- x raised to the power of 2 -
$sqrt(x)-float- square root of x -
$cbrt(x)-float- cube root of x -
$exp(x)-float- e raised to the power of x -
$exp2(x)-float- 2 raised to the power of x -
$log(x, y)-float- The base-y logarithm of x -
$logn(x)-float- The natural logarithm of x -
$log2(x)-float- The base-2 logarithm of x -
$log10(x)-float- The base-10 logarithm of x -
$lerp(x, y, amount)-float- Performs a linear interpolation between two values based on the given weight. Params: x — The first value, which is intended to be the lower bound. y — The second value, which is intended to be the upper bound. amount — A value between 0 and 1, that indicates the weight of the interpolation. -
$dialog(dialogKey)-string- Gets the dialog associated with the given dialog key. -
$truncate(x)-float- Truncates the value. -
$round(x)-float- Rounds the given value to the nearest even number. -
$vec(x, y)-Vector2- Creates aVector2from the given coordinates.