moved adding of default village types out of add_village_type.lua

This commit is contained in:
Sokomine 2023-07-11 06:11:37 +02:00
parent bf3a58d381
commit 65119c7ec3
2 changed files with 90 additions and 46 deletions

View File

@ -1,3 +1,91 @@
---------------------------
-- 1. Add village types ---
---------------------------
-- DOCUMENTATION: mg_villages.village_type_data has entries in the following form:
-- key = { data values } with key beeing the name of the village type
-- meaning of the data values:
-- min, max: the village size will be choosen randomly between these two values;
-- the actual village will have a radius about twice as big (including sourrounding area)
-- space_between_buildings=2 How much space is there between the buildings. 1 or 2 are good values.
-- The higher, the further the buildings are spread apart.
-- mods = {'homedecor','moreblocks'} List of mods that are required for the buildings of this village type.
-- List all the mods the blocks used by your buildings which are not in default.
-- texture = 'wool_white.png' Texture used to show the location of the village when using the
-- vmap command.
-- name_prefix = 'Village ',
-- name_postfix = '' When creating village names for single houses which are spawned outside
-- of villages, the village name will consist of name_prefix..village_name..name_postfix
-- sapling_divisor = 1 Villages are sourrounded by a flat area that may contain trees. Increasing this
-- value decreses the mount of trees placed.
-- plant_type = 'farming:wheat_8' Type of plant that is placed around villages.
-- plant_frequency = 1 The higher this value is, the less plants are placed.
local village_type_data_list = {
nore = { min = 20, max = 40, space_between_buildings=1, mods={}, texture = 'default_stone_brick.png',
replacement_function = mg_villages.replacements_nore },
taoki = { min = 30, max = 70, space_between_buildings=1, mods={}, texture = 'default_brick.png' ,
sapling_divisor = 5, plant_type = 'farming:cotton_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_taoki },
medieval = { min = 25, max = 60, space_between_buildings=2, mods={'cottages'}, texture = 'cottages_darkage_straw.png', -- they often have straw roofs
sapling_divisor = 10, plant_type = 'farming:wheat_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_medieval,
roadsize_list = {2,3,4,5,6},
-- road_materials = {'default:cobble','default:gravel','default:stonebrick','default:coalblock'},
}, --roadsize_list = {1,1,2,3,4} },
charachoal = { min = 10, max = 15, space_between_buildings=1, mods={'cottages'}, texture = 'default_coal_block.png',
replacement_function = mg_villages.replacements_charachoal },
lumberjack = { min = 10, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_tree.png', name_prefix = 'Camp ',
sapling_divisor = 1, plant_type = 'default:junglegrass', plant_frequency = 24,
replacement_function = mg_villages.replacements_lumberjack },
claytrader = { min = 10, max = 20, space_between_buildings=1, mods={'cottages'}, texture = 'default_clay.png',
replacement_function = mg_villages.replacements_claytrader },
logcabin = { min = 15, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_wood.png',
replacement_function = mg_villages.replacements_logcabin },
grasshut = { min = 10, max = 40, space_between_buildings=1, mods={'dryplants'}, texture = 'dryplants_reed.png',
replacement_function = mg_villages.replacements_grasshut },
tent = { min = 5, max = 20, space_between_buildings=2, mods={'cottages'}, texture = 'wool_white.png', name_preifx = 'Tent at',
replacement_function = mg_villages.replacements_tent },
-- these sub-types may occour as single houses placed far from villages
tower = { only_single = 1, name_prefix = 'Tower at ', mods={'cottages'}, texture = 'default_mese.png',
replacement_function = mg_villages.replacements_tower },
chateau = { only_single = 1, name_prefix = 'Chateau ', texture = 'default_gold_block.png',
replacement_function = mg_villages.replacements_chateau },
forge = { only_single = 1, name_prefix = 'Forge at '},
tavern = { only_single = 1, name_prefix = 'Inn at '},
well = { only_single = 1, name_prefix = 'Well at ',
replacement_function = mg_villages.replacements_medieval },
trader = { only_single = 1, name_prefix = 'Trading post ' },
sawmill = { only_single = 1, name_prefix = 'Sawmill at ' },
farm_tiny = { only_single = 1, name_prefix = 'House '},
farm_full = { only_single = 1, name_prefix = 'Farm '},
single = { only_single = 1, name_prefix = 'House '}, -- fallback
}
-- NOTE: Most values of village types added with mg_villages.add_village_type can still be changed later on by
-- changing the global variable mg_villages.village_type_data[ village_type ]
-- Village types where one or more of the required mods (listed in v.mods) are missing will not be
-- available.
-- You can add your own village type by i.e. calling
-- mg_villages.add_village_type( 'town', { min = 10, max = 30, space_between_buildings = 2, mods = {'moreblocks','homedecor'}, texture='default_diamond_block.png'} );
-- This will add a new village type named 'town', which will only be available if the mods moreblocks and homedecor are installed.
-- It will show the texture of the diamond block when showing the position of a village of that type in the map displayed by the /vmap command.
-- add our village types
for k,v in pairs( village_type_data_list ) do
mg_villages.add_village_type( k, v )
end
-- just to show that this local list is no longer needed
village_type_data_list = nil
------------------------------------
-- 2. Add buildings (schematics) ---
------------------------------------
-- scm="bla" Name of the file that holds the buildings' schematic. Supported types: .we and .mts (omit the extension!)
-- sizex, sizez, ysize: obsolete
-- yoff=0 how deep is the building burried?
@ -275,3 +363,5 @@ for i,v in ipairs( buildings ) do
v.mts_path = mts_path
mg_villages.add_building( v, i )
end
-- just to show that this local list is no longer needed
buildings = nil

View File

@ -18,50 +18,8 @@
-- plant_type = 'farming:wheat_8' Type of plant that is placed around villages.
-- plant_frequency = 1 The higher this value is, the less plants are placed.
-- Intllib
local S = mg_villages.intllib
local village_type_data_list = {
nore = { min = 20, max = 40, space_between_buildings=1, mods={}, texture = 'default_stone_brick.png',
replacement_function = mg_villages.replacements_nore },
taoki = { min = 30, max = 70, space_between_buildings=1, mods={}, texture = 'default_brick.png' ,
sapling_divisor = 5, plant_type = 'farming:cotton_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_taoki },
medieval = { min = 25, max = 60, space_between_buildings=2, mods={'cottages'}, texture = 'cottages_darkage_straw.png', -- they often have straw roofs
sapling_divisor = 10, plant_type = 'farming:wheat_8', plant_frequency = 1,
replacement_function = mg_villages.replacements_medieval,
roadsize_list = {2,3,4,5,6},
-- road_materials = {'default:cobble','default:gravel','default:stonebrick','default:coalblock'},
}, --roadsize_list = {1,1,2,3,4} },
charachoal = { min = 10, max = 15, space_between_buildings=1, mods={'cottages'}, texture = 'default_coal_block.png',
replacement_function = mg_villages.replacements_charachoal },
lumberjack = { min = 10, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_tree.png', name_prefix = 'Camp ',
sapling_divisor = 1, plant_type = 'default:junglegrass', plant_frequency = 24,
replacement_function = mg_villages.replacements_lumberjack },
claytrader = { min = 10, max = 20, space_between_buildings=1, mods={'cottages'}, texture = 'default_clay.png',
replacement_function = mg_villages.replacements_claytrader },
logcabin = { min = 15, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_wood.png',
replacement_function = mg_villages.replacements_logcabin },
grasshut = { min = 10, max = 40, space_between_buildings=1, mods={'dryplants'}, texture = 'dryplants_reed.png',
replacement_function = mg_villages.replacements_grasshut },
tent = { min = 5, max = 20, space_between_buildings=2, mods={'cottages'}, texture = 'wool_white.png', name_preifx = 'Tent at',
replacement_function = mg_villages.replacements_tent },
-- these sub-types may occour as single houses placed far from villages
tower = { only_single = 1, name_prefix = 'Tower at ', mods={'cottages'}, texture = 'default_mese.png',
replacement_function = mg_villages.replacements_tower },
chateau = { only_single = 1, name_prefix = 'Chateau ', texture = 'default_gold_block.png',
replacement_function = mg_villages.replacements_chateau },
forge = { only_single = 1, name_prefix = 'Forge at '},
tavern = { only_single = 1, name_prefix = 'Inn at '},
well = { only_single = 1, name_prefix = 'Well at ',
replacement_function = mg_villages.replacements_medieval },
trader = { only_single = 1, name_prefix = 'Trading post ' },
sawmill = { only_single = 1, name_prefix = 'Sawmill at ' },
farm_tiny = { only_single = 1, name_prefix = 'House '},
farm_full = { only_single = 1, name_prefix = 'Farm '},
single = { only_single = 1, name_prefix = 'House '}, -- fallback
}
-- NOTE: Most values of village types added with mg_villages.add_village_type can still be changed later on by
-- changing the global variable mg_villages.village_type_data[ village_type ]
@ -116,7 +74,3 @@ end
-- build a list of all useable village types the mg_villages mod comes with
mg_villages.village_type_data = {};
for k,v in pairs( village_type_data_list ) do
mg_villages.add_village_type( k, v );
end
village_type_data_list = nil;