added replacement function for village types
parent
fe241a08ed
commit
32cedbc3a0
6
init.lua
6
init.lua
|
@ -27,6 +27,9 @@ dofile(mg_villages.modpath.."/nodes.lua")
|
||||||
-- the default game no longer provides helpful tree growing code
|
-- the default game no longer provides helpful tree growing code
|
||||||
dofile(mg_villages.modpath.."/trees.lua")
|
dofile(mg_villages.modpath.."/trees.lua")
|
||||||
|
|
||||||
|
-- replace some materials for entire villages randomly
|
||||||
|
dofile(mg_villages.modpath.."/replacements.lua")
|
||||||
|
|
||||||
-- multiple diffrent village types with their own sets of houses are supported
|
-- multiple diffrent village types with their own sets of houses are supported
|
||||||
-- The function mg_villages.add_village_type( village_type_name, village_type_data )
|
-- The function mg_villages.add_village_type( village_type_name, village_type_data )
|
||||||
-- allows other mods to add new village types.
|
-- allows other mods to add new village types.
|
||||||
|
@ -40,9 +43,6 @@ dofile(mg_villages.modpath.."/buildings.lua")
|
||||||
-- been added using the functions above
|
-- been added using the functions above
|
||||||
dofile(mg_villages.modpath.."/init_weights.lua")
|
dofile(mg_villages.modpath.."/init_weights.lua")
|
||||||
|
|
||||||
-- replace some materials for entire villages randomly
|
|
||||||
dofile(mg_villages.modpath.."/replacements.lua")
|
|
||||||
|
|
||||||
-- generate village names
|
-- generate village names
|
||||||
dofile(mg_villages.modpath.."/name_gen.lua");
|
dofile(mg_villages.modpath.."/name_gen.lua");
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,8 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
-- deco is used by BigFreakingDig; as that one lacks default nodes, it doesn't work out here
|
||||||
if( wood_found and minetest.get_modpath('deco')) then
|
if( wood_found and minetest.get_modpath('deco')) then
|
||||||
local bfd_treelist = {'birch', 'cherry', 'evergreen', 'oak' };
|
local bfd_treelist = {'birch', 'cherry', 'evergreen', 'oak' };
|
||||||
for _,v in ipairs( bfd_treelist ) do
|
for _,v in ipairs( bfd_treelist ) do
|
||||||
|
@ -83,6 +85,7 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--]]
|
||||||
|
|
||||||
if( wood_found and mg_villages.ethereal_trees ) then
|
if( wood_found and mg_villages.ethereal_trees ) then
|
||||||
for _,v in ipairs( mg_villages.ethereal_trees ) do
|
for _,v in ipairs( mg_villages.ethereal_trees ) do
|
||||||
|
@ -285,10 +288,17 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
table.insert( replacements, {'default:obsidian_glass', 'default:glass' });
|
table.insert( replacements, {'default:obsidian_glass', 'default:glass' });
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if( housetype and mg_villages.village_type_data[ housetype ] and mg_villages.village_type_data[ housetype ].replacement_function ) then
|
||||||
|
return mg_villages.village_type_data[ housetype ].replacement_function( housetype, pr, replacements );
|
||||||
|
end
|
||||||
|
return replacements;
|
||||||
|
end
|
||||||
|
|
||||||
local wood_type = 'default:wood';
|
|
||||||
-- Taokis houses from structure i/o
|
|
||||||
if( housetype == 'taoki' ) then
|
-- Taokis houses from structure i/o
|
||||||
|
mg_villages.replacements_taoki = function( housetype, pr, replacements )
|
||||||
|
local wood_type = 'default:wood';
|
||||||
|
|
||||||
if( mg_villages.realtest_trees ) then
|
if( mg_villages.realtest_trees ) then
|
||||||
wood_type = mg_villages.replace_materials( replacements, pr,
|
wood_type = mg_villages.replace_materials( replacements, pr,
|
||||||
|
@ -343,10 +353,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
'brick' );
|
'brick' );
|
||||||
|
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'nore' ) then
|
mg_villages.replacements_nore = function( housetype, pr, replacements )
|
||||||
|
|
||||||
mg_villages.replace_materials( replacements, pr,
|
mg_villages.replace_materials( replacements, pr,
|
||||||
-- {'default:stonebrick'},
|
-- {'default:stonebrick'},
|
||||||
|
@ -374,11 +384,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
table.insert( replacements, {'stairs:slab_cobble', 'default:stone_bricks_slab' });
|
table.insert( replacements, {'stairs:slab_cobble', 'default:stone_bricks_slab' });
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'lumberjack' ) then
|
mg_villages.replacements_lumberjack = function( housetype, pr, replacements )
|
||||||
|
|
||||||
-- replace the wood - those are lumberjacks after all
|
-- replace the wood - those are lumberjacks after all
|
||||||
local wood_type = mg_villages.replace_materials( replacements, pr,
|
local wood_type = mg_villages.replace_materials( replacements, pr,
|
||||||
{'default:wood'},
|
{'default:wood'},
|
||||||
|
@ -392,10 +401,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
table.insert( replacements, {'bell:bell', 'default:goldblock' });
|
table.insert( replacements, {'bell:bell', 'default:goldblock' });
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'canadian' ) then
|
mg_villages.replacements_canadian = function( housetype, pr, replacements )
|
||||||
|
|
||||||
table.insert( replacements, {'4seasons:slimtree_wood', 'default:fence_wood'});
|
table.insert( replacements, {'4seasons:slimtree_wood', 'default:fence_wood'});
|
||||||
if( true) then return replacements; end -- TODO
|
if( true) then return replacements; end -- TODO
|
||||||
|
@ -447,10 +456,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
end
|
end
|
||||||
|
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'logcabin' ) then
|
mg_villages.replacements_logcabin = function( housetype, pr, replacements )
|
||||||
|
|
||||||
-- for logcabins, wood is the most likely type of roof material
|
-- for logcabins, wood is the most likely type of roof material
|
||||||
local roof_type = mg_villages.replace_materials( replacements, pr,
|
local roof_type = mg_villages.replace_materials( replacements, pr,
|
||||||
|
@ -489,10 +498,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
'default:junglewood');
|
'default:junglewood');
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'chateau' ) then
|
mg_villages.replacements_chateau = function( housetype, pr, replacements )
|
||||||
|
|
||||||
if( minetest.get_modpath( 'cottages' )) then
|
if( minetest.get_modpath( 'cottages' )) then
|
||||||
-- straw is the most likely building material for roofs for historical buildings
|
-- straw is the most likely building material for roofs for historical buildings
|
||||||
|
@ -545,10 +554,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
'cobble');
|
'cobble');
|
||||||
|
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'tent' ) then
|
mg_villages.replacements_tent = function( housetype, pr, replacements )
|
||||||
table.insert( replacements, { "glasspanes:wool_pane", "cottages:wool_tent" });
|
table.insert( replacements, { "glasspanes:wool_pane", "cottages:wool_tent" });
|
||||||
table.insert( replacements, { "default:gravel", "default:sand" });
|
table.insert( replacements, { "default:gravel", "default:sand" });
|
||||||
-- realtest needs diffrent fence posts and doors
|
-- realtest needs diffrent fence posts and doors
|
||||||
|
@ -562,11 +571,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
mg_villages.replace_saplings( replacements, wood_type );
|
mg_villages.replace_saplings( replacements, wood_type );
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'grasshut' ) then
|
mg_villages.replacements_grasshut = function( housetype, pr, replacements )
|
||||||
|
|
||||||
table.insert( replacements, {'moreblocks:fence_jungle_wood', 'default:fence' });
|
table.insert( replacements, {'moreblocks:fence_jungle_wood', 'default:fence' });
|
||||||
if( pr:next( 1, 4) == 1 ) then
|
if( pr:next( 1, 4) == 1 ) then
|
||||||
table.insert( replacements, {'dryplants:reed_roof', 'cottages:roof_straw'});
|
table.insert( replacements, {'dryplants:reed_roof', 'cottages:roof_straw'});
|
||||||
|
@ -587,10 +595,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
|
|
||||||
table.insert( replacements, {'default:desert_sand', 'default:dirt_with_grass' });
|
table.insert( replacements, {'default:desert_sand', 'default:dirt_with_grass' });
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'claytrader' ) then
|
mg_villages.replacements_claytrader = function( housetype, pr, replacements )
|
||||||
-- the walls of the clay trader houses are made out of brick
|
-- the walls of the clay trader houses are made out of brick
|
||||||
mg_villages.replace_materials( replacements, pr,
|
mg_villages.replace_materials( replacements, pr,
|
||||||
{ 'stairs:stair_brick', 'stairs:slab_brick', 'default:brick' }, -- default_materials
|
{ 'stairs:stair_brick', 'stairs:slab_brick', 'default:brick' }, -- default_materials
|
||||||
|
@ -643,10 +651,10 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
'sandstone');
|
'sandstone');
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if( housetype == 'charachoal' ) then
|
mg_villages.replacements_charachoal = function( housetype, pr, replacements )
|
||||||
if( mg_villages.realtest_trees ) then
|
if( mg_villages.realtest_trees ) then
|
||||||
local wood_type = mg_villages.replace_materials( replacements, pr,
|
local wood_type = mg_villages.replace_materials( replacements, pr,
|
||||||
{'default:wood'},
|
{'default:wood'},
|
||||||
|
@ -660,13 +668,11 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
table.insert( replacements, {'stairs:stair_loam', 'cottages:loam'});
|
table.insert( replacements, {'stairs:stair_loam', 'cottages:loam'});
|
||||||
end
|
end
|
||||||
return replacements;
|
return replacements;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- wells can get the same replacements as the sourrounding village; they'll get a fitting roof that way
|
-- wells can get the same replacements as the sourrounding village; they'll get a fitting roof that way
|
||||||
if( housetype ~= 'medieval' and housetype ~= 'well' and housetype ~= 'cottages') then
|
mg_villages.replacements_medieval = function( housetype, pr, replacements )
|
||||||
return replacements;
|
|
||||||
end
|
|
||||||
|
|
||||||
if( not( minetest.get_modpath('bell' ))) then
|
if( not( minetest.get_modpath('bell' ))) then
|
||||||
table.insert( replacements, {'bell:bell', 'default:goldblock' });
|
table.insert( replacements, {'bell:bell', 'default:goldblock' });
|
||||||
|
|
|
@ -19,26 +19,38 @@
|
||||||
-- plant_frequency = 1 The higher this value is, the less plants are placed.
|
-- plant_frequency = 1 The higher this value is, the less plants are placed.
|
||||||
|
|
||||||
local village_type_data_list = {
|
local village_type_data_list = {
|
||||||
nore = { min = 20, max = 40, space_between_buildings=1, mods={}, texture = 'default_stone_brick.png'},
|
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' ,
|
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 },
|
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
|
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 },
|
sapling_divisor = 10, plant_type = 'farming:wheat_8', plant_frequency = 1,
|
||||||
charachoal = { min = 10, max = 15, space_between_buildings=1, mods={'cottages'}, texture = 'default_coal_block.png'},
|
replacement_function = mg_villages.replacements_medieval },
|
||||||
|
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 ',
|
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 },
|
sapling_divisor = 1, plant_type = 'default:junglegrass', plant_frequency = 24,
|
||||||
claytrader = { min = 10, max = 20, space_between_buildings=1, mods={'cottages'}, texture = 'default_clay.png'},
|
replacement_function = mg_villages.replacements_lumberjack },
|
||||||
logcabin = { min = 15, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_wood.png'},
|
claytrader = { min = 10, max = 20, space_between_buildings=1, mods={'cottages'}, texture = 'default_clay.png',
|
||||||
canadian = { min = 40, max = 110, space_between_buildings=1, mods={'hdb','nbu'}, texture = 'wool_white.png'},
|
replacement_function = mg_villages.replacements_claytrader },
|
||||||
grasshut = { min = 10, max = 40, space_between_buildings=1, mods={'dryplants'}, texture = 'dryplants_reed.png'},
|
logcabin = { min = 15, max = 30, space_between_buildings=1, mods={'cottages'}, texture = 'default_wood.png',
|
||||||
tent = { min = 5, max = 20, space_between_buildings=2, mods={'cottages'}, texture = 'wool_white.png', name_preifx = 'Tent at'},
|
replacement_function = mg_villages.replacements_logcabin },
|
||||||
|
canadian = { min = 40, max = 110, space_between_buildings=1, mods={'hdb','nbu'}, texture = 'wool_white.png',
|
||||||
|
replacement_function = mg_villages.replacements_canadian },
|
||||||
|
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
|
-- 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'},
|
tower = { only_single = 1, name_prefix = 'Tower at ', mods={'cottages'}, texture = 'default_mese.png'},
|
||||||
chateau = { only_single = 1, name_prefix = 'Chateau ', texture = 'default_gold_block.png'},
|
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 '},
|
forge = { only_single = 1, name_prefix = 'Forge at '},
|
||||||
tavern = { only_single = 1, name_prefix = 'Inn at '},
|
tavern = { only_single = 1, name_prefix = 'Inn at '},
|
||||||
well = { only_single = 1, name_prefix = 'Well at '},
|
well = { only_single = 1, name_prefix = 'Well at ',
|
||||||
|
replacement_function = mg_villages.replacements_medieval },
|
||||||
trader = { only_single = 1, name_prefix = 'Trading post ' },
|
trader = { only_single = 1, name_prefix = 'Trading post ' },
|
||||||
sawmill = { only_single = 1, name_prefix = 'Sawmill at ' },
|
sawmill = { only_single = 1, name_prefix = 'Sawmill at ' },
|
||||||
farm_tiny = { only_single = 1, name_prefix = 'House '},
|
farm_tiny = { only_single = 1, name_prefix = 'House '},
|
||||||
|
|
Loading…
Reference in New Issue