Skip to content

WorldGenerator

Fills its Tilemap with a world made from a Seed: rolling hills of grass over dirt, stone below with caves and veins of ore, sand, trees, and a floor that can’t be dug through. The same seed always makes the same world; 0 makes a new one every time.

Part of the Block Worlds module: Block worlds, Terraria style: worlds made from a seed (WorldGenerator), blocks that break, fall, glow and are kept in the save data (Blocks), digging and building (BlockBuilder), a Hotbar and Crafting, and the Sandbox template.

With GenerateOnPlay the map’s tiles are replaced by a fresh world each time the game starts (unless a saved world comes back, see Blocks.SaveAs); untick it to keep the world as painted. Tile numbers are the map’s tileset’s: -1 leaves a feature out.

Requires: Tilemap (the world it fills)

Works with: Blocks (so the world can be dug up and built on)

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • seed: a whole number = 1. Picks the world: the same number always makes the same one. 0 makes a new world each time. (Field: a number.)
  • generateOnPlay: true or false = true. Make the world when the game starts. Untick it to keep (and paint on) the map as it is. (Field: on or off.)
  • width: a whole number = 120. Cells across. (Field: a number.)
  • height: a whole number = 60. Cells down, sky included. (Field: a number.)
  • surface: a whole number = 18. Rows of sky above the ground, on average. (Field: a number.)
  • hills: a number = 5. How many cells the ground rises and falls. (Field: a number.)
  • hillWidth: a number = 28. About how many cells from one hilltop to the next. (Field: a number.)
  • grassTile: a whole number = 0. The tile on top of the ground. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • dirtTile: a whole number = 1. The tile under the grass, DirtDepth cells deep. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • stoneTile: a whole number = 2. The tile under the dirt, all the way down. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • dirtDepth: a whole number = 5. How many cells of dirt lie under the grass before the stone starts. (Field: a number.)
  • caves: a number = 0.3. How much of the underground is caves, from 0 (solid) to 1 (mostly hollow). 0.3 is plenty. (Field: a number.)
  • ores: text = “3 6%, 4 3%”. Ores in the stone: a tile and how much of the stone it makes up, separated by commas, e.g. “3 6%, 4 3%”. Each comes in little veins; the second and later ores lie deeper. (Tiles and their share, separated by commas: a tile (or a range, 3-4) and a number with %, e.g. “3 6%”. The Inspector lists them a row each with the tile picked off the tileset.) (Field: its own editor: Tile Amounts.)
  • sand: a number = 0.15. Patches of sand along the surface, from 0 (none) to 1 (everywhere). (Field: a number.)
  • sandTile: a whole number = -1. The tile for patches of sand; -1 for none. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • trees: a number = 0.15. How often a tree grows on the grass, from 0 (never) to 1 (wherever there’s room). (Field: a number.)
  • trunkTile: a whole number = -1. The tile for tree trunks; -1 for no trees. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • leavesTile: a whole number = -1. The tile for treetops; -1 for none. (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • bottomTile: a whole number = -1. A tile for the bottom row, usually one that’s unbreakable (see Blocks.Unbreakable). (Tiles of the tilemap’s tilesets by number (the first tileset’s from 0, the next’s from 100, then 200…): a string of numbers and ranges like “10-15, 20”, or for a whole number one tile. The Inspector shows the tiles to click.) (Field: its own editor: Tile Numbers.)
  • walls: text = null. The name of another tilemap to fill with the walls of the underground, drawn behind the world: what caves and tunnels show instead of the sky. Give it the same position and tileset, no collisions (untick Solid), a darker tint, and a lower Order. (Names an entity.) (Field: an entity’s name.)
  • spawn: text = “Player”. Entities to stand on the ground in the middle of the world once it’s made, by name, separated by commas, e.g. “Player”. (Names entities: their names, separated by commas.) (Field: an entity’s name.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • usedSeed: a whole number. The seed the world was last made from: the one picked when Seed is 0.

Scripts use it as WorldGenerator: its methods, events and values that aren’t saved with the scene.