-
A small convenience when writing float values: you can input an expression, like
pi
,pi / 2
or2/3
instead of typing the actual value (3.14…, 1.57…, 0.6666….).Any expression using CastleScript is allowed.
This is nice e.g. for angles for which we use radians (consistent with X3D, OpenGL, many other APIs). So you have to think in terms of pi (not degrees). At least now you can write
pi/2
instead of calculating1.57...
in some external calculator. (An even better solution, to both display and edit angles in degrees, like just180deg
that just meanspi
automatically, is possible in the future. My main fear with it is that people will get confused that API still expects radians, and passingAngle:=180
will not work as expected. So for now, you have to use radians all across CGE, but it’s just easier now.)It is nice for any other use-case when it’s easier to write an expression than result.
1/3
,2/3
,10+1/3
are some examples.As a funny example of abusing this, note that you can even use
random
function from CastleScript π So you can input in CGE editor valuerandom()
and get different result each time π I’m sure it’s a unique feature of CGE that you can assign an unpredictable value to a property πThis is all just an “editing convenience”. The value is calculated immediately as you change focus / press Enter, and it is stored as a simple float (not as CastleScript expression) in the actual property, in serialized JSON etc.
We have also changed the division operators in CastleScript to work like in Pascal:
/
makes float division,div
makes integer division.If you want to use such expression in your own applications, go ahead: just call
ParseConstantFloatExpression
instead ofStrToFloat
. -
The “Output” tab has a simple context menu (right-click). It allows to clean it, copy selected line, copy all lines (to the clipboard). Great to copy-parse error message to show it someone.
-
I have changed the editor start form. No revolution (yet — I do have a more interesting redesign on a TODO list), I just wanted to expose nice buttons to open examples and support us on Patreon.
Editor improvements: input floats like “pi/2” or “2+2”, context menu for “Output”, new start form
Start the discussion at Castle Game Engine Forum