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. |
A global declared at the outermost level has its initialiser computed exactly once, at game start. It is not recomputed every frame - which is most of "the value is stuck at whatever it was first". epScript does not quietly run triggers you did not place. A local declared inside a function is the opposite: its initialiser runs every time that line does.
const count = dwread_epd(...); // 전역: 시작할 때 한 번 / once, at startup
var count; // 선언만 하고
function beforeTriggerExec() {
count = dwread_epd(...); // 원하는 자리에서 대입
}Values are unsigned, so zero minus two is 0xFFFFFFFE - 4,294,967,294. But it is two's complement, so comparing against a negative literal works anyway: a < -1 and a > -3 are both true, and a == -3 is true. It behaves exactly like unsigned in C.
The trap is a > 0. The comparison is unsigned, so a negative is larger than every positive: a > 0 is true even when a is -2. To ask whether a is negative, test the sign bit with a >= 0x80000000. And which subtraction you used matters: a -= 2 adds the two's complement and goes negative, while DoActions(a.SubtractNumber(2)) is the raw action and floors at zero.
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]];