This shows you the differences between two versions of the page.
modding:developerinfo:townbuilding [2019/03/19 10:18] |
modding:developerinfo:townbuilding [2019/03/19 10:18] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Town buildings ===== | ||
+ | |||
+ | Town buildings are a subcategory of construction files. Although town buildings can be configured in the same way as any other construction, they have certain restrictions and conditions. | ||
+ | |||
+ | ==== Overview ==== | ||
+ | |||
+ | Town buildings are stored as ''.con'' files in the folder ''res\construction\building''. | ||
+ | |||
+ | Each era has its own subfolder: | ||
+ | * ''res\construction\building\era_a'': until 1900 | ||
+ | * ''res\construction\building\era_b'': 1900 to 1975 | ||
+ | * ''res\construction\building\era_c'': from 1975 | ||
+ | |||
+ | ==== make_buildings function ==== | ||
+ | |||
+ | To ensure town buildings fulfil all needed requirements, the function ''make_building'' is used to create town buildings. | ||
+ | |||
+ | The function is located in the script ''res\scripts\townbuildingutil.lua''. | ||
+ | |||
+ | <code lua> | ||
+ | function townbuildingutil.make_building(constructionModelId, buildingModelId, buildingFace, transf, landUseType, era, size, parcelSize, assets) | ||
+ | </code> | ||
+ | |||
+ | === Function parameters === | ||
+ | |||
+ | * ''constructionModelId'': link to a model file to be placed during the construction | ||
+ | * ''buildingModelId'': link to the building model file | ||
+ | * ''buildingFace'': list of 2D coordinates | ||
+ | * ''transf'': transformation relative to parcel center | ||
+ | * ''landUseType'': ''"RESIDENTIAL"'', ''"COMMERCIAL"'', or ''"INDUSTRIAL"'' | ||
+ | * ''era'': ''"A"'', ''"B"'', or ''"C"'' | ||
+ | * ''size'': building size (1 to 5) | ||
+ | * ''parcelSize'': parcel size, from 1x1 to 4x5 (resp. ''{ 1, 1 }'' to ''{ 4, 5 }'') | ||
+ | * ''assets'': list of model files to be placed around the building | ||
+ | |||
+ | ==== Complete code example ==== | ||
+ | |||
+ | <code lua> | ||
+ | local townbuildingutil = require "townbuildingutil" | ||
+ | local transf = require "transf" | ||
+ | local vec3 = require "vec3" | ||
+ | |||
+ | function data() | ||
+ | |||
+ | return townbuildingutil.make_building( | ||
+ | "asset/construction_1850.mdl", | ||
+ | "building/era_a/res_1_1x1_01_02.mdl", | ||
+ | { { -4.00, -1.25 }, { 4.00, -1.25 }, { 4.00, 8.00 }, { -4.00, 8.00 } }, | ||
+ | transf.transl(vec3.new(.0, 1.5, .0)), | ||
+ | "COMMERCIAL", "A", 1, | ||
+ | { 1, 1 }, | ||
+ | { | ||
+ | -- list of grp and ids | ||
+ | } | ||
+ | ) | ||
+ | |||
+ | end | ||
+ | </code> | ||
+ | |||
+ | === grp and ids === | ||
+ | |||
+ | A ''grp'' is a categorized collection of decorative model files. One (or none) of the models are chosen at random and placed at the specified position. | ||
+ | |||
+ | ''ids'' are model files, which are placed at the specified position. | ||
+ | |||
+ | === Example === | ||
+ | <code> | ||
+ | { | ||
+ | grp = "era_a_com_1_wall_sign", | ||
+ | transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.8, 2.725, 2.5, 1 } | ||
+ | }, | ||
+ | |||
+ | { | ||
+ | ids = { "building/era_a/com_1_asset_wall_awning_03_start.mdl" }, | ||
+ | transf = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.5, 2.725, 1.5, 1 } | ||
+ | }, | ||
+ | </code> | ||
+ | |||
+ | Available ''grp'' files: | ||
+ | * ''bench'' | ||
+ | * ''era_a_ind_random_decoration'' | ||
+ | * ''era_b_ind_random_decoration'' | ||
+ | * ''era_c_ind_random_decoration'' | ||
+ | * ''era_a_res_random_decoration'' | ||
+ | * ''era_b_res_random_decoration'' | ||
+ | * ''era_c_res_random_decoration'' | ||
+ | * ''random_roof_decoration_small'' | ||
+ | * ''random_roof_decoration_large'' | ||
+ | * ''solar_panel_on_off'' | ||
+ | * ''era_c_pavillion_on_off'' | ||
+ | * ''era_a_com_random_decoration'' | ||
+ | * ''era_b_com_random_decoration'' | ||
+ | * ''era_b_com_1_ground_box'' | ||
+ | * ''era_b_com_1_ground_food_booth'' | ||
+ | * ''era_b_com_1_ground_sign'' | ||
+ | * ''era_b_com_1_wall_sign_big'' | ||
+ | * ''era_b_com_1_wall_sign_small'' | ||
+ | * ''era_b_com_1_wall_store_sign_big'' | ||
+ | * ''era_b_com_1_wall_store_sign_small'' | ||
+ | * ''era_b_com_2_to_3_wall_sign_big'' | ||
+ | * ''era_b_com_2_to_3_wall_sign_small'' | ||
+ | * ''era_b_com_2_to_3_wall_store_sign'' | ||
+ | * ''era_b_com_2_to_3_wall_store_sign_small'' | ||
+ | * ''era_c_com_random_decoration'' | ||
+ | * ''era_a_com_1_food_booth'' | ||
+ | * ''era_a_com_1_wall_sign'' | ||
+ | * ''era_a_com_1_wall_sign_big'' | ||
+ | * ''era_a_com_1_ground_sign'' | ||
+ | * ''era_a_com_1_wall_store_sign'' | ||
+ | * ''era_a_com_2_wall_sign'' | ||
+ | * ''era_a_com_2_roof_sign'' | ||
+ | * ''era_a_com_2_wall_store_sign'' | ||
+ | * ''era_a_com_2_wall_store_sign_big'' | ||
+ | * ''era_a_com_2_wall_awning_04'' | ||
+ | * ''era_c_com_2_to_4_wall_sign_small'' | ||
+ | * ''era_c_com_2_to_4_wall_sign_large'' | ||
+ | * ''era_c_com_2_to_4_wall_store_sign'' | ||
+ | * ''silo_horizontal'' | ||
+ | * ''silo_vertical'' | ||
+ | * ''silo_special'' | ||
+ | * ''garden_sunshade_large_01'' | ||
+ | * ''garden_sunshade_large_02'' | ||
+ | * ''garden_sunshade_small'' | ||
+ | * ''random_medium_tree'' | ||
+ | * ''random_large_tree'' | ||
+ | * ''random_small_tree'' | ||
+ | * ''random_shrub_europe'' | ||
+ | * ''random_shrub_usa'' | ||
+ | |||
+ | For more detailed information about the categories, please refer to the ''townbuildingutil.assets'' list in the ''townbuildingutil.lua'' script. | ||