Nearly every older source is written in addresses - wwrite(0x666160 + 2*spriteId, ...) and the like. euddraft ships a named layer over all of it, and the name is scdata. It arrived in 0.9.11.0 and has been extended in almost every release since.
TrgUnit("Zerg Mutalisk").flingy = "Kakaru";
Image("Firebat Shadow").drawingFunction = "EMPShockwave";
Weapon("Gauss Rifle").damage = 30;Members chain: one that names another table hands you that table's object.
unit.armor += 1;
unit.groundWeapon.damage += 1; // Weapon을 거쳐서 / through Weapon
unit.groundWeapon = Weapon("Gauss Rifle"); // 무기 자체를 교체 / or replace it outrightA player is an object too: resources read as fields, and the read is a condition.
P1.ore += 1;
if (P1.ore >= 100) printAll("빨강이 미네랄 100 이상");And the current level of an upgrade or a tech is indexed by player, which replaces every piece of code that computed an upgrade-level address by hand.
const infantryWeapon = Upgrade("Terran Infantry Weapon");
foreach(player : EUDLoopPlayer()) { infantryWeapon[player] = 1; }
printAll("1피 레벨: {}", infantryWeapon[P1]);
var spiderMines: Tech = "Spider Mines";
spiderMines[P1] = 1;
once (Tech("Stim Pack")[P1]) { printAll("빨강이 스팀팩을 업그레이드했습니다."); }One caution. TrgUnit, Weapon, Upgrade and the rest address tables, so they change the whole map. To change one unit you want CUnit - the same distinction the structure-offsets lesson is about.
A variable can be given an scdata type, and knowing that the implementation caches derived values is what makes the cost predictable.
| 4바이트 멤버 | Accessed directly, with no cache check. |
|---|---|
| 1·2바이트 멤버 | Each access adds a cache-check condition and recomputes the derived values if the variable changed. |
| 인스턴스 += 1 | Special-cased to update the cache in place, so no invalidation happens. Prefer it to re-assignment when walking a table. |
| 캐시는 변수에 붙습니다 | The cache belongs to the variable: cast one variable to two types and the bitmask widens to the larger, so one type's cost shows up in the other's accesses. |
One behaviour change to know when reading older code: cast no longer copies the value, it reinterprets in place. Code written before 0.10.0.0 that relied on a cast producing a separate variable is wrong now.
Structure offsetsdat writes do not stay written