Skip to content
Fungi

Build houses from blueprint modules

Assemble buildings from rooms with doors, windows and doorways, then stand them up as real, breakable buildables.

A town is many buildings, and a building is a few rooms. Blueprints let you describe a room once and reuse it. Declare a room as a module: its size in cells, the openings on its sides, and named slots inside it for your game’s containers or furniture:

TS
import { assembleBlueprint, blueprintModule } from "vishnu";
const living = blueprintModule("acorn.living", {
size: [4, 3],
openings: [
{ side: "south", at: 1, kind: "door" },
{ side: "east", at: 1, kind: "doorway" },
],
slots: { sofa: [0, 0] },
});
const kitchen = blueprintModule("acorn.kitchen", {
size: [3, 3],
openings: [{ side: "north", at: 1, kind: "window" }],
slots: { fridge: [2, 0] },
});
const cottage = assembleBlueprint({
modules: [
{ module: living, at: [10, 4] },
{ module: kitchen, at: [14, 4] },
],
});

A recipe places each module by its north-west corner. It can also turn a module (rotate, in clockwise quarter turns) or mirror it east to west. assembleBlueprint joins the rooms into one building:

  • a wall two rooms share becomes one piece;
  • a doorway leaves an open gap into the next room;
  • everything else on the outside becomes a wall, a door or a window.

The same recipe always gives the same pieces in the same order, so a seeded town is the same town forever.

Then stand it up with your own buildables:

TS
import { compileBlueprint, prebuildBatches } from "vishnu";
const { plans, unplaced } = compileBlueprint(cottage, {
construction: acornConstruction,
pieces: { wall: "acorn.wall", door: "acorn.door", window: "acorn.window" },
groundAt: (x, z) => ground.get(`${x},${z}`),
});
for (const action of prebuildBatches(partyId, plans)) context.action(action);

Every piece is a real buildable. Players can deconstruct it, repair it, or break it (see Prebuilt and breakable structures). A piece over a column with no ground is not placed; it is listed in unplaced for you to handle. prebuildBatches splits the plans into prebuild actions of at most 256 structures each.

Assembling refuses, with a coded diagnostic:

  • two rooms that overlap;
  • a doorway that leads outside;
  • two rooms that disagree about a wall they share, such as a door on one side and a window on the other.

Blueprints are single-storey.