Since there's not currently any UI to pick expressions, here's a list of all expressions currently supported in C2.
[size=150:1o1zlee0]General expression features[/size:1o1zlee0]
There are no expression shortcuts like in 0.x: you can't type .X as a substitute for Self.X. However, the Self keyword works.
You can specify specific instances in object expressions: Sprite(0).X gets the first picked Sprite's X co-ordinate, Sprite(1).X the second, and so on. Sprite(N) when there are N sprites will wrap-around and return the first Sprite's X again, Sprite(N+1) the second, and so on. Sprite(-1).X will return the last picked Sprite's X co-ordinate, Sprite(-2).X the second last, and so on. You can use any expression for the instance to pick, you don't have to just enter a number.
The usual arithmetic operators are supported: + - * / % ^
There's a new unary minus operator, so you can write -Sprite.X instead of 0 - Sprite.X.
The conditional a ? b : c operator was a bit buggy in 0.x - it should be working correctly in C2. Example: Sprite.X < 100 ? -1 : 1
The & operator is string concatenation as in 0.x, or logical AND when both operands are numbers. The | operator is logical OR (and has no special behavior with strings).
int(x) - convert x to integer
float(x) - convert x to float
str(x) - convert x to string
len(x) - return length of the string x
random(x) - return a random float from 0 (inclusive) to x (exclusive) - note this differs from Construct 0.x where random would return an integer if you passed it an integer. Use int(random(x)) to reproduce this behavior.
random(a, b) - return a random float from a (inclusive) to b (exclusive).
sqrt(x) - compute square root of x.
abs(x) - absolute (positive) value of x.
round(x) - round x to the nearest whole number.
floor(x) - round x to the lowest next whole number.
ceil(x) - round x to the highest next whole number.
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x) - trigonometric functions, which work in degrees
exp(x) - e raised to the power x
ln(x) - log to base e of x
log10(x) - log to base 10 of x
lerp(a, b, x) - linearly interpolate a to b by x
distance(x1, y1, x2, y2) - distance between two points
angle(x1, y1, x2, y2) - angle between two points (degrees)
loopindex - current (top-level) loop index
loopindex(name) - loop index of 'for' loop of given name
max(x, y [, z...]), min(x, y [, z...]) - returns maximum/minimum of any number passed - like 0.x you can pass any number of parameters here.
newline - text string containing a line break character.
timescale - always 1.0 at this time.
time - time in seconds since the game started.
tickcount - number of ticks elapsed since the game started.
objectcount - total number of object instances in the game.
fps - current framerate in frames per second.
scrollx, scrolly - current scroll position
[size=150:1o1zlee0]Common object expressions[/size:1o1zlee0]
Currently, Sprite and Text implement these.
X, Y, Width, Height - as with 0.x
Angle - (Sprite only) Angle in degrees
Count - number of instances
[size=150:1o1zlee0]Other object expressions[/size:1o1zlee0]
There are no longer MouseX or MouseY system expressions - insert the Mouse object and use Mouse.X and Mouse.Y for the mouse position in the layout, or Mouse.AbsoluteX and Mouse.AbsoluteY for the position on the canvas.
The text object also has a 'Text' expression (surprise!).
Access these by their name like this:
You can't name an instance variable the same as an object expression.