Coming from another language, this is the first thing that catches you. epScript has exactly one value type: a 32-bit unsigned integer. No floats, no separate boolean, and no string variables at all.
The reason is in an earlier lesson: a variable is the number field of a trigger action, and that field is a four byte integer. The language is not designed this way so much as there is nowhere else to put anything.
| var | A variable whose value changes in game. It occupies a trigger. |
|---|---|
| const | A name assigned once. It may hold a runtime value but cannot be reassigned. |
| static | Declared inside a function but surviving between calls - the alternative to a row of numbered globals. |
Values are unsigned. Zero minus one is 4,294,967,295, not -1. And subtraction floors at zero, so which operation you used changes the answer - this is the most common bug in EUD code that deals with negatives.
A function can return several values as a compile-time tuple, and you pick one out with double brackets.
function minmax(a, b) {
if (a < b) { return a, b; }
return b, a;
}
const lo = minmax(x, y)[[0]];
const hi = minmax(x, y)[[1]];