Manyland

An Area Generator is JavaScript which automatically sets the placements across all the area. Click the "Try" link in the Generator section of the area dialog to prepare one. Once finished, copy your code, and click "Create" to paste it into the text area of the block type "Area Generator" found in the "Automation" category. Now you can click the generator icon back in the area dialog to attach that creation.

Every generator contains a function generate, which is called repeatedly to ask you for what to put in specific locations of the area. The following, for instance, places a back block at every odd x position within the whole area, and draws a minfinitely long solid bridge at the start position:

var ids = {
    solid: '538a6912502702986a653db0',
    back: '53ed06283b84acbe1ab61513',
    climbable: '55bf2a8d2b753d6a5f02ba17'
};

function generate(data) {
    var placements = [];
    var bridgeY = data.spawnPosition.y + 1;

    for (var i = 0; i < data.sectors.length; i++) {
        var sector = data.sectors[i];
        for (var x = sector.x1; x <= sector.x2; x++) {
            for (var y = sector.y1; y <= sector.y2; y++) {
                if (y == bridgeY) {
                    placements.push({id: ids.solid, x: x, y: y});
                }
                else if (isOdd(x)) {
                    placements.push({id: ids.climbable, x: x, y: y});
                }
            }
        }
    }
    
    return {placements: placements};
}

function isOdd(v) {
    return v % 2 != 0;
}

The following data fields are passed to your generate function:

sectorsAn array of sectors. (This is always guaranteed to be an array.)
areaNameThe current root area name. (This is always a defined string.)
subAreaNameThe current sub-area name (or null if not a sub-area).
spawnPositionThe x and y position integers of where new people launch in this area.

The {} data structure you need to return contains the single field placements, which is an array where each item has these properties:

id The identifier of the block. Get it by Shift-Right-clicking a block in the world, or (if the script editor is open) by clicking a block in the world, which copies its id to your clipboard. mandatory
x The x coordinate of the placement. mandatory
y The y coordinate of the placement. mandatory
rotation A value from 0-3 to rotate the block. optional
flip Flips the block horizontally if set to 1. optional

→ When several people see each other in the area, the resulting placements must be the same per coordinate, or the generator may not run. For this reason, the native random() function is overwritten to generate a deterministic random result.

→ Note to see generative areas by others, your setting "Run Automations by Others" needs to be ticked (as it is by default).

→ The maximum range to generate placements for is currently +/-1 million for x and y.

Logging

You can use the following functions to log debug information when the script editor is opened (you can pass as many parameters as you like):

log('hello', 5); 
 
logOnce(x); // Only logs once per run 
 
logFresh(1 + 1); // Clears the log and logs something new 
 
logFresh(); // Clears the log 

Native Functions

Extra functions available to generators are listed here.

More...

Also check out the main introductory help.