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.2048fxDecimal 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.14fBehind the scenes, the transpiler will convert these numbers to their equivalent value based on the environment settings:
- In
LevelandSharedit will convert these numbers to their fixedpoint counterparts (100.5fwill become100.2048fx) - In
MeshandSoundfixed 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.14rWhen using angle literals, the transpiler will automatically convert their values:
- The
dliteral allows you to write angles in degrees. They are automatically converted to radians and directly placed in the final Lua code. - The
rliteral is functionally the same as a decimalfliteral, keeping its value without ther. It is useful to denote when arguments are angles or just numbers.
Other Literals
Section titled “Other Literals”0xis a hexadecimal literal. Example:0xff0ois an octal literal. Example:0o070bis a binary literal. Example:0b01