SCRMaps
/
Sign in

There is only one kind of value

Every epScript variable is a 32-bit unsigned integer. There is no such thing as a string variable.

6 min read

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.

Declarations
varA variable whose value changes in game. It occupies a trigger.
constA name assigned once. It may hold a runtime value but cannot be reassigned.
staticDeclared 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(...);        // 원하는 자리에서 대입
}
Two fixes: declare it as a local inside the function that uses it, or declare the global without an initialiser and assign to it from somewhere that actually runs.

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]];
This is a compile-time selection, not a runtime array.