SCRMaps
/
Sign in

How a script is laid out

Globals, helpers, and the entry point that runs every cycle.

4 min read

EPScript files are written in much the same order every time. With no hoisting, the order is the structure.

  1. 1Global declarations - the values that must persist per player.
  2. 2Helper functions - the small ones that read and write values.
  3. 3Feature functions - the ones that actually do something.
  4. 4The entry points - beforeTriggerExec and afterTriggerExec.
function beforeTriggerExec(){
    EUDPlayerLoop()();

    updateStatusLine();
    handleKeyEvent();

    EUDEndPlayerLoop();
}

function afterTriggerExec(){
}
EUD Editor 3 calls these two by name. Both must exist even when one of them is empty.

Globals are declared one per player. There are no arrays here, so the usual approach is to number the names and pick between them with a branch.

var gold_0; var gold_1; var gold_2; var gold_3;
var gold_4; var gold_5; var gold_6; var gold_7;

function getGold(){
    var p = f_getcurpl();
    if(p == 0){ return gold_0; }
    else if(p == 1){ return gold_1; }
    else if(p == 2){ return gold_2; }
    // ... 나머지 플레이어
    return 0;
}
It looks verbose, and it is the standard shape. Rather than typing it, describe the structure and have it built - “a per-player function holding gold” produces exactly this.

Globals start at zero. Treating zero as “not started yet” usually makes the code shorter than writing an explicit initialisation.

Sign in to track your progress