Number literals
In PPL, you use number literals with fx
at the end of the number. But thankfully, Hybroid Live makes working with numbers easier, by giving several options.
Fixedpoint Literal
Section titled “Fixedpoint Literal”Use fx
to explicitly state you want to use fixedpoint numbers. This feature is disallowed in Generic
, Mesh
and Sound
environments.
let speed = 100.2048fx
Decimal Literal
Section titled “Decimal Literal”If that’s not what you want, Hybroid Live gives the option to use generic decimal literals by writing a float and adding f
at the end
let a = 100.5flet b = 3.14f
Behind the scenes, the transpiler will convert these numbers to their equivalent value based on the environment settings:
- In
Level
andShared
it will convert these numbers to their fixedpoint counterparts (100.5f
will become100.2048fx
) - In
Mesh
andSound
fixed of any kind is not allowed
Angle Literal
Section titled “Angle Literal”Hybroid Live also adds special literal support for angles.
let degrees = 180dlet pi = 3.14r
When using angle literals, the transpiler will automatically convert their values:
- The
d
literal allows you to write angles in degrees. They are automatically converted to radians and directly placed in the final Lua code. - The
r
literal is functionally the same as a decimalf
literal, keeping its value without ther
. It is useful to denote when arguments are angles or just numbers.
Other Literals
Section titled “Other Literals”0x
is a hexadecimal literal. Example:0xff
0o
is an octal literal. Example:0o07
0b
is a binary literal. Example:0b01