EPScript files are written in much the same order every time. With no hoisting, the order is the structure.
- 1Global declarations - the values that must persist per player.
- 2Helper functions - the small ones that read and write values.
- 3Feature functions - the ones that actually do something.
- 4The entry points - beforeTriggerExec and afterTriggerExec.
function beforeTriggerExec(){
EUDPlayerLoop()();
updateStatusLine();
handleKeyEvent();
EUDEndPlayerLoop();
}
function afterTriggerExec(){
}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;
}Globals start at zero. Treating zero as “not started yet” usually makes the code shorter than writing an explicit initialisation.
