Skip to content
Sokomine edited this page Nov 15, 2015 · 3 revisions

##7. Buildings

All villages are constructed by arranging pre-built houses (schematics) alongside roads.

A building can be stored using WorldEdit, handle_schematics or any other mod that can save either in WorldEdit format (.we, .wem), minetest schematic format (.mts), or even a schematic (.schematic) exported from an MC program.

Calling mg_villages.add_building( building_data ) adds the building which is described in the table building_data.

###7.1 Internal structure of building_data

Location of the schematic:

  • mts_path (required) the path to the folder holding the schematic
  • scm (required) the file name of the schematic

How deep is it burried?

  • yoff Can be determined automaticly if the building was saved using handle_schematics.

Limit rotation and mirroring if needed:

  • orients (optional) Table containing the allowed rotations. It can be {0,1,2,3} or a subset thereof. The value will be determined automaticly if the building was saved using handle_schematics.
  • axis (optional) If set to 1, the building will be mirrored alongside the x-axis instead of the z-axis when mirroring. This is necessary if the building is already rotated by 90 or 270 degrees.
  • nomirror (optional) If set to 1, the building shall not be mirrored (for some nodes mirroring just doesn't work).
  • no_rotate (optional) Forbid rotation entirely. May be useful in cases where rotation along the y-axis does not change the building anyway, so we can save us the trouble of calculating it.
  • we_origin (optional) compatibility mode for very old WorldEdit files that do not start at 0,0,0

In which types of villages will the building appear, and how frequently?

  • weight = table A table containing an entry for each village type the building is supposed to appear in. The value has to be larger than 0. The higher the weight is, the more likely it is that the building will be choosen and placed inside the village. Use a fraction of 1 for rarer buildings (wells, benches, ..) and a high value for more important ones (town hall, church, school, forge, shop, ..)
  • pervillage Limits how many buildings of type typ will be allowed in any village.
  • avoid Avoid to be placed next to buildings of type typ. There is no guarantee that two such buildings will never be placed next to each other, but we do at least try.
  • typ The type of the building, which is relevant for pervillage and avoid. Check the existing buildings in order to find fitting types for your buildings. There is no fixed set.

Further optional parameters:

  • farming_plus If set to 1, cotton plants in the building/on the field will be replaced with a random fruit
  • inh number of mobs that may live here (number of beds); if negative: number of mobs that work here; useful only for determining how many inhabitants the village has (and how many mobs to spawn)

Values used internally:

  • sizex, sizez, ysize: dimensions of the building; will be determined automaticly from the file
  • not_available will be set by mg_villages.add_building(..) to 1 if none of the village types listed in the weight table can be used (=mods it requires are installed)
  • is_mts (internal)
  • rotated (internal)
  • nodenames (internal) list of nodenames contained in the schematic/we file
  • on_constr (internal) list of nodenames for which on_construct has to be called
  • after_place_node(interal) list of nodenames for which after_place_node has to be called
  • scm_data_cache (internal) representation of the schematic in a 3d lua table

###7.2 Example

Example of adding a simple house: mg_villages.add_building( { scm="sandcity_tiny_3_1_270", mts_path=path, weight={sandcity=1, single=1}, inh=nil, typ='house'}) The line above will add the building found in the file schems/sandcity_tiny_3_1_270, which was saved using handle_schematics. It will be used for the village type sandcity and single (which stands for lone houses).

A more complex example: {scm="forge_1", yoff= 0, orients={0}, farming_plus=0, avoid='', typ='forge', weight={medieval=2, single=1/2}, pervillage=1, inh=-1} The schematic is saved in the file forge_1, it is not burried in the ground (yoff=0), orientated correctly, does not grow any intresting farming products, is of (internal) type forge, has a priority of 2 (normal houses: 1) in medieval villages, while having a priority of 1/2 (=less frequent) if used as a lone house, can occour once per village (pervillage=1), and has one mob (inh=-1) working, but not living, there.

Clone this wiki locally