SCRMaps
/
Sign in

eudplib: map data and the build

Opening the map, turning names into numbers, and saving it.

5 min read

euddraft calls most of these for you, but knowing the shape of the build makes its errors far easier to read.

Opening and saving
LoadMap(fname)Open a map and read all of its CHK data.
SaveMap(fname, rootf)Save the map with rootf as its entry point.
EUDOnStart(func)Register a function to run when the map starts.
EUDDoEvents()Yield the trigger loop where you stand.
GetChkTokenized()Read and write CHK sections directly. Leave STR and TRIG alone.
MPQAddFile(fname, content, isWave) / MPQAddWave(fname, content)Put a file or a WAV inside the map's MPQ.
IsMapdataInitalized()Whether the map data has been loaded yet.
Names into numbers
EncodeUnit / EncodeLocation / EncodeString / EncodeSwitch / EncodePlayerTurn a name into the number a trigger uses. Not always the same as the index.
EncodeAIScript / EncodeAllyStatus / EncodeComparison / EncodeCount / EncodeModifier / EncodeOrder / EncodePropState / EncodeProperty / EncodeResource / EncodeScore / EncodeSwitchAction / EncodeSwitchStateThe same conversion for every other argument type.
GetUnitIndex / GetLocationIndex / GetStringIndex / GetSwitchIndex / GetPropertyIndexTurn a name into its index.
GetPlayerInfo(player)Fetch a player's information.
UnitProperty(...)Build the property bundle CreateUnitWithProperties takes.
Build options
CompressPayload(mode)Compress the payload to shrink the map. On by default in euddraft.
EP_SetRValueStrictMode(mode)Forbid assigning into an expression result. Off by default.
PRT_SetInliningRate(rate)How much of TRIG to move into STR. It increases map size.
eudplibVersion()Report the eudplib version.

Saving runs in three phases, and knowing which one failed narrows the cause considerably.

  1. 1Collection - work out the address relationships and gather every object the map needs.
  2. 2Allocation - decide each object's address from its size.
  3. 3Writing - lay the data down at those addresses.

Forward() is the forward declaration for when you need something's address before you have defined it - common when triggers point at each other.

Sign in to track your progress