Skip to content

Blocks

Makes a Tilemap a world of blocks to dig up and build with: what each tile gives when it’s mined, what each item puts down, how long blocks take to break, blocks that can’t be broken, sand that falls, and torches that glow. A BlockBuilder on the player does the digging and building.

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.

Requires: Tilemap (the blocks)

Works with: WorldGenerator (to make the world); BlockBuilder (on the player, to dig and build)

Gives off light in a dark scene.

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.

  • items: lines of text: an array of strings, or one string with line breaks = []. The blocks the player can carry and put down, one per row: the item’s name and its tile, e.g. “Dirt 1”. Mining a tile gives the item named for it here, unless Drops says otherwise. (Blocks to carry and put down, one per row: the item’s name and its tile, e.g. “Dirt 1”. The Inspector lists them a row each with the tile picked off the tileset.) (Field: its own editor: Block Items.)
  • drops: text = null. Tiles that give something else when mined: a tile and an item, separated by commas, e.g. “0 Dirt, 6 Sapling”. “6 nothing” gives nothing. (Tiles that give something else when mined, separated by commas: a tile and an item, e.g. “0 Dirt, 6 Sapling” (“6 nothing” gives nothing). The Inspector lists them a row each with the tile picked off the tileset.) (Field: its own editor: Tile Drops.)
  • mineTime: a number = 0.35. Seconds it takes to break a block, unless Hardness says otherwise. (Field: a number.)
  • hardness: text = null. Blocks that take longer (or less long) to break: tiles and seconds, separated by commas, e.g. “2 0.8, 3-4 1.2”. (Tiles and their seconds, separated by commas: a tile (or a range, 3-4) and a number, e.g. “3 0.8”. The Inspector lists them a row each with the tile picked off the tileset.) (Field: its own editor: Tile Amounts.)
  • unbreakable: text = null. Tiles that can’t be broken, like the bottom of the world: tile numbers and ranges, e.g. “9”. (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.)
  • fallingTiles: text = null. Tiles that fall when there’s nothing under them, like sand and gravel: tile numbers and ranges. (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.)
  • glowingTiles: text = null. Tiles that give off light, like torches and lava: tile numbers and ranges. They light up a dark scene (a camera with an Camera.Ambient light) like a Light would. (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.)
  • glowRadius: a number = 5. How far the light of a glowing tile reaches, in world units. (Field: a number.)
  • glowColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#FFC87AFF”. The color of the light glowing tiles give off. (Field: a color.)
  • underground: a color, “#RRGGBB” or “#RRGGBBAA” = “#00000000”. How dark it gets underground: as the camera goes below the ground (where it was when the game started), its light fades to this color, and torches and other glowing blocks light the way. Transparent keeps it bright everywhere. (Field: a color.)
  • darkDepth: a number = 8. How far below the surface it takes to get fully dark, in world units. (Field: a number.)
  • saveAs: text = null. A name to keep the world under in the game’s save data, e.g. “World”: what was dug and built comes back next time the game runs, instead of a new world. Empty starts over each time. (Names a name in the save data: this entity’s own, which other fields can name.) (Field: a name.)
  • breakEffect: text = null. A prefab spawned where a block breaks, e.g. a puff of dust. (Names a prefab.) (Field: a name.)
  • digSound: text = null. A sound played while digging, each time a block cracks a little more. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • breakSound: text = null. A sound played when a block breaks. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • placeSound: text = null. A sound played when a block is put down. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)

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