Go to file
BuckarooBanzay 3ff18186ec add `default` and `moreblocks` to hard-deps
fixes #4 and #5
2022-05-14 20:14:20 +02:00
.github/workflows drop some more stuff 2021-01-21 19:54:58 +01:00
layouts layouts in text files 2021-10-01 14:15:22 +02:00
renderers render api 2021-09-30 16:07:54 +02:00
schematics use options.on_metadata for street signs 2021-06-20 10:59:34 +02:00
util convert street list to newline list 2021-09-30 15:36:00 +02:00
.luacheckrc tabula rasa 2021-01-21 19:42:22 +01:00
12-slice.png docs about the 12-slice schematic 2021-02-16 13:27:13 +01:00
api.lua render api 2021-09-30 16:07:54 +02:00
chatcommands.lua closed edges wip 2021-01-29 15:43:01 +01:00
cityblock.lua more layouts 2021-10-01 13:08:03 +02:00
debug.lua /cityblock_debug command 2021-09-03 20:52:39 +02:00
default_buildings.lua iron variant of building3 2021-02-02 16:44:17 +01:00
hacks.lua add optimize-distance hack/fix 2021-09-07 13:40:38 +02:00
init.lua add `default` and `moreblocks` to hard-deps 2022-05-14 20:14:20 +02:00
layout.lua layouts in text files 2021-10-01 14:15:22 +02:00
layout_parser.lua layouts in text files 2021-10-01 14:15:22 +02:00
mapgen.lua render api 2021-09-30 16:07:54 +02:00
mod.conf add `default` and `moreblocks` to hard-deps 2022-05-14 20:14:20 +02:00
perlin_manager.lua modularize 2021-01-29 16:45:50 +01:00
readme.md update readme 2021-10-01 14:16:37 +02:00
screenshot.png update docs 2021-02-16 13:14:26 +01:00
util.lua modularize 2021-01-29 16:45:50 +01:00

readme.md

citygen -- minetest city mapgenerator


A mod for minetest

ContentDB

Overview

Generates a procedural city with prefabricated blocks and some randomization

Recommended optional mods

  • morelights for the streetlights and sewer lighting
  • street_signs for the streetname signs

Updating the mod

Breaking changes can happen at any time, don't upgrade the mod if you plan on keeping you world-cityscape consistent!

How it works

The map is divided into 20 mapblocks along the z and x axis, called the "cityblock". Those 20-mapblock squares are plotted once (and cached) with a predefined layout depending on their position on the map. Streets are always aligned to the sides of the cityblock. Relevant files for the layouting mechanism:

To ensure that the generated data is always the same a perlin-noise is derived from the current position of the cityblock. The perlin generation is done in perlin_manager.lua

A plotted cityblock looks like this (a table with x and z axes):

cityblock = {
	{
		{ -- x axis
			{ -- z axis
				groups = {
					building = true,
					edge = true
				},
				attributes = {
					building_type = "citygen:default_building2",
					height = 5
				},
				direction = "x+",
			},
			{
				groups = {
					building = true,
					edge = true
				},
				attributes = {
					building_type = "citygen:default_building2",
					height = 5
				},
				direction = "x+",
			},
			{
				groups = {
					building = true,
					corner = true
				},
				attributes = {
					building_type = "citygen:default_building2",
					height = 5
				},
				direction = "x+z+",
			}
		}
	},
	-- the
	root_pos = {
		z = 600,
		x = 720
	}
}

This data can be dumped on the console with the ingame command /cityblock. The current mapblock data can be dumped with /cityblock_mapblock. The "root_pos" is the lower, left mapblock of the cityblock.

This data is then passed to each mapblock that needs to be generated by the mapgen (See: mapgen.lua)

The streetnames are picked randomly (depending on the x/z position of the street) from a catalog (See: streetname.lua)

The premade schematics are deseiralized onto the map with the help of the mapblock_lib. Some buildings have different variants with custom node-replacements, see: default_buildings.lua

The schematics for a building contain 12 parts that get assembled depending on their position (bottom, corner, etc). An example of the 12 parts in "exploded" view:

Each part can be edited by copying the files (manifest- and bin-file) out of the schematics/building/ folder and placing them into the <worldfolder>/mapblocks/ folder.

Loading and saving the parts from the world and to disk is done with the mapblock_lib commands:

  • /mapblock_load <name>
  • /mapblock_save <name>

For example:

mkdir /my/world/mapblocks
cp schematics/street/street_all_sides* /my/world/mapblocks/

Ingame: /mapblock_load street_all_sides for loading and /mapblock_save street_all_sides to save

Licenses

Code

  • MIT