SCRMaps
/
Sign in

The syntax, in one place

What real maps actually use is a narrower language than you would expect.

3 min read

EPScript looks broadly like C or JavaScript. Open a shipped map's script, though, and the syntax in use is startlingly narrow: var, function, if/else and return account for almost all of it.

Declarations
var name = 0;Declare a variable - local inside a function, global outside one.
function name(){ }Declare a function, which may take arguments and return a value.
// 주석A line comment.
Control
if(cond){ } else { }A conditional, with else if available.
return value;Return a value.
&&Logical and - in practice the only operator used to chain conditions.
== / !=Equal and not equal.
+ - * / %Arithmetic and remainder.

A condition can be a trigger condition rather than just a value comparison. That is the heart of EPScript: the conditions and actions you already know are all callable as functions.

function giveReward(){
    var amount = 0;
    if(Deaths(CurrentPlayer, AtLeast, 100, "Level") && Command(CurrentPlayer, AtLeast, 1, "Terran Marine")){
        amount = 500;
    }
    if(amount == 0){ return; }
    SetDeaths(CurrentPlayer, Add, amount, "Gold");
    DisplayText("\x13\x07보상을 받았습니다");
}
Deaths() is a condition so it goes inside the if; SetDeaths() is an action so it stands as a statement.

Declarations must precede use. There is no hoisting, so a global a function reads has to be declared above it - which is why globals are conventionally gathered at the top of the file.

The language has loops, but shipped scripts barely use them. The trigger cycle is already a loop, so most repetition is left to the cycle and filtered with conditions instead.

Sign in to track your progress