This script itself is just a template; unmodified, it ends up not doing anything, but with data added in, SwitchMaster.crpl can use it to generate a map. You need one copy of it for every additional map phase you want on the map.
The information from ReadMapData.crpl goes in the four functions in this script: GetUnits, GetDigitalis, GetWalls, and GetTerrainRow. For all but GetTerrainRow, just place the relevant information right after the function definition. For instance, GetUnits might look something like this:
:GetUnits
41 39 3600 2250 1 50000000 "SPORETOWER"
20 42 250 "ENERGY" "RESOURCEPACK"GetTerrainRow has slightly more strict requirements than the other three functions. Particularly, the contents of this function must be between
once and
return endonce. Splitting this data into multiple
once ... return endonce blocks will reduce the lag that occurs on any given frame as the new terrain is being generated. Due to CRPL being stack-based, the order of the blocks is reversed from when it's a single block. For instance:
once 7 14 -1 2 7 3 -1 3 4 6 7 5 4 3 7 10 return endoncewould become
once 3 4 6 7 5 4 3 7 10 return endonce
once 7 14 -1 2 7 3 -1 3 return endonceIf you split the blocks, be
absolutely sure that every block has an even number of numbers inside of it. If not, the terrain will become
very messed up.
Unit formats
For any single unit, the first two items are its x and y positions on the map. The last item is the unit type. A nullifier at coordinate (13, 70) would look like the following, for instance:
13 70 "NULLIFIER"
Depending on the unit, there may or may not be more items in between.
Emitters have three additional arguments: time until they start emitting (seconds), time between emitting (seconds), and amount of creeper emitted (units of creeper).
Spore towers have four additional arguments: build time (seconds), wave interval (seconds), number of spores, and spore payload (units of creeper).
Air exclustion towers have 1 additional argument: range (tiles).
Runner nests have 5 additional arguments: runner spawn interval (seconds), max runner population, runner move speed, runner health, and runner creeper payload (units of creeper).
Inhibitors have 4 additional arguments: time until they start emitting (seconds), time between emitting (seconds), amount of creeper emitted (units of creeper), and range of anti-AoO field.
Resource packs have 2 additional arguments: resource amount and resource type (string).
Artifacts of Odin have 1 additional argument: type (as a string).
Guppy pads have 1 additional argument: type (as a string).
Tech artifacts have 2 additional arguments: tech type (as a string), and count (-1 for unlimited).
CRPL cores are complicated, and can have arbitrarily many arguments. The last additional argument states how many scripts are attatched to the core.
The format for each script is as follows: the last item is the script name, the second-to-last item is the number of variables for that script, and the rest of the items are alternating variable names and variable values. The value comes after the name of the variable.
All other units have no additional arguments.
Terrain format
The terrain information is pairs of heights and how many of that terrain there is in a row. For instance, the numbers 7 13 describe a section of 13 tiles of height-7 terrain.
The major catch is that, because CRPL is stack-based, this information starts at the bottom-right of the map if you read the numbers from start to end. If you read it the direction the (stack-based) script does, it describes the map row-by-row, starting on the top left corner and moving right along the row. Once it reaches the end of a row, it begins at the left of the next row.
Digitalis and wall format
These are basically the same format as the terrain. Instead of heights, however, they use boolean values of whether there is digitalis/wall. 1 = digi/wall, 0 = no digi/wall.