improved replacement handling; improved replacements for realtest
parent
fdeeca7ff0
commit
6bd67226b9
|
@ -686,13 +686,6 @@ mg_villages.place_villages_via_voxelmanip = function( villages, minp, maxp, vm,
|
||||||
cid.c_ethereal_clay_orange = minetest.get_content_id( 'bakedclay:orange' );
|
cid.c_ethereal_clay_orange = minetest.get_content_id( 'bakedclay:orange' );
|
||||||
end
|
end
|
||||||
|
|
||||||
cid.c_chest = minetest.get_content_id( 'default:chest' );
|
|
||||||
cid.c_chest_locked = minetest.get_content_id( 'default:chest_locked' );
|
|
||||||
cid.c_chest_private = minetest.get_content_id( 'cottages:chest_private' );
|
|
||||||
cid.c_chest_work = minetest.get_content_id( 'cottages:chest_work' );
|
|
||||||
cid.c_chest_storage = minetest.get_content_id( 'cottages:chest_storage' );
|
|
||||||
cid.c_chest_shelf = minetest.get_content_id( 'cottages:shelf' );
|
|
||||||
cid.c_sign = minetest.get_content_id( 'default:sign_wall' );
|
|
||||||
|
|
||||||
t1 = time_elapsed( t1, 'defines' );
|
t1 = time_elapsed( t1, 'defines' );
|
||||||
--[[
|
--[[
|
||||||
|
|
|
@ -12,6 +12,14 @@ if( minetest.get_modpath( 'trees' )
|
||||||
and minetest.get_modpath( 'scribing_table' )) then
|
and minetest.get_modpath( 'scribing_table' )) then
|
||||||
mg_villages.realtest_trees = {'ash','aspen','birch','maple','chestnut','pine','spruce'};
|
mg_villages.realtest_trees = {'ash','aspen','birch','maple','chestnut','pine','spruce'};
|
||||||
--print('REALTEST trees will be used.'); else print( 'NO REALTEST trees');
|
--print('REALTEST trees will be used.'); else print( 'NO REALTEST trees');
|
||||||
|
|
||||||
|
-- realtest is very special as far as stairs are concerned
|
||||||
|
mg_villages.realtest_stairs = {'default:stone','default:stone_flat','default:stone_bricks',
|
||||||
|
'default:desert_stone','default:desert_stone_flat','default:desert_stone_bricks'};
|
||||||
|
for i,v in ipairs(metals.list) do
|
||||||
|
table.insert( mg_villages.realtest_stairs, 'metals:'..v..'_block' );
|
||||||
|
end
|
||||||
|
-- the list of minteral names is local; so we can't add "decorations:"..mineral[1].."_block"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,23 +28,22 @@ end
|
||||||
mg_villages.replace_materials = function( replacements, pr, original_materials, prefixes, materials, old_material )
|
mg_villages.replace_materials = function( replacements, pr, original_materials, prefixes, materials, old_material )
|
||||||
|
|
||||||
local postfixes = {};
|
local postfixes = {};
|
||||||
|
local use_realtest_stairs = false;
|
||||||
-- handle realtest stairs/slabs
|
-- handle realtest stairs/slabs
|
||||||
if( mg_villages.realtest_trees
|
if( mg_villages.realtest_trees
|
||||||
and #prefixes==3
|
and #prefixes==3
|
||||||
and prefixes[1]=='stairs:stair_' and prefixes[2]=='stairs:slab_' and prefixes[2]=='default:' ) then
|
and prefixes[1]=='stairs:stair_' and prefixes[2]=='stairs:slab_' and prefixes[3]=='default:' ) then
|
||||||
|
|
||||||
prefixes = {'default:','default:','default:'};
|
prefixes = {''};
|
||||||
materials = {'stone', 'stone_flat', 'desert_stone', 'desert_stone_flat', 'cobbleblock_flat', 'brick', 'stone_bricks', 'desert_stone_bricks' };
|
materials = mg_villages.realtest_stairs;
|
||||||
postfixes = {'_stair', '_slab', ''};
|
postfixes = {''};
|
||||||
|
use_realtest_stairs = true;
|
||||||
|
|
||||||
elseif( mg_villages.realtest_trees
|
elseif( mg_villages.realtest_trees
|
||||||
and #prefixes==1
|
and #prefixes==1
|
||||||
and prefixes[1]=='stairs:stair_') then
|
and prefixes[1]=='stairs:stair_') then
|
||||||
|
|
||||||
prefixes = {'trees:'};
|
return;
|
||||||
materials = mg_villages.realtest_trees;
|
|
||||||
postfixes = {'_planks_stair'};
|
|
||||||
|
|
||||||
else
|
else
|
||||||
for i,v in ipairs( prefixes ) do
|
for i,v in ipairs( prefixes ) do
|
||||||
postfixes[i] = '';
|
postfixes[i] = '';
|
||||||
|
@ -108,6 +115,13 @@ mg_villages.replace_materials = function( replacements, pr, original_materials,
|
||||||
end
|
end
|
||||||
local new_material = known_materials[ pr:next( 1, #known_materials )];
|
local new_material = known_materials[ pr:next( 1, #known_materials )];
|
||||||
|
|
||||||
|
if( use_realtest_stairs == true ) then
|
||||||
|
table.insert( replacements, { original_materials[ 1 ], new_material..'_stair' } );
|
||||||
|
table.insert( replacements, { original_materials[ 2 ], new_material..'_slab' } );
|
||||||
|
table.insert( replacements, { original_materials[ 3 ], new_material } );
|
||||||
|
return new_material;
|
||||||
|
end
|
||||||
|
|
||||||
-- no replacement necessary if we did choose the same material as before
|
-- no replacement necessary if we did choose the same material as before
|
||||||
if( new_material == old_material or old_material == (prefixes[1]..new_material)) then
|
if( new_material == old_material or old_material == (prefixes[1]..new_material)) then
|
||||||
return old_material;
|
return old_material;
|
||||||
|
@ -163,10 +177,12 @@ mg_villages.replace_tree_trunk = function( replacements, wood_type )
|
||||||
table.insert( replacements, {'default:tree', "trees:"..v..'_log'});
|
table.insert( replacements, {'default:tree', "trees:"..v..'_log'});
|
||||||
-- realtest does not have most of the nodes from default, so we need to replace them as well
|
-- realtest does not have most of the nodes from default, so we need to replace them as well
|
||||||
table.insert( replacements, {'default:wood', 'trees:'..v..'_planks'});
|
table.insert( replacements, {'default:wood', 'trees:'..v..'_planks'});
|
||||||
|
table.insert( replacements, {'default:leaves', 'trees:'..v..'_leaves'});
|
||||||
table.insert( replacements, {'default:ladder', 'trees:'..v..'_ladder'});
|
table.insert( replacements, {'default:ladder', 'trees:'..v..'_ladder'});
|
||||||
table.insert( replacements, {'default:chest', 'trees:'..v..'_chest'});
|
table.insert( replacements, {'default:chest', 'trees:'..v..'_chest'});
|
||||||
table.insert( replacements, {'default:chest_locked', 'trees:'..v..'_chest_locked'});
|
table.insert( replacements, {'default:chest_locked', 'trees:'..v..'_chest_locked'});
|
||||||
table.insert( replacements, {'default:fence_wood', 'fences:'..v..'_fence'});
|
table.insert( replacements, {'default:fence_wood', 'fences:'..v..'_fence'});
|
||||||
|
table.insert( replacements, {'default:bookshelf', 'decorations:bookshelf_'..v});
|
||||||
table.insert( replacements, {'doors:door_wood_t_1', 'doors:door_'..v..'_t_1'});
|
table.insert( replacements, {'doors:door_wood_t_1', 'doors:door_'..v..'_t_1'});
|
||||||
table.insert( replacements, {'doors:door_wood_b_1', 'doors:door_'..v..'_b_1'});
|
table.insert( replacements, {'doors:door_wood_b_1', 'doors:door_'..v..'_b_1'});
|
||||||
table.insert( replacements, {'doors:door_wood_t_2', 'doors:door_'..v..'_t_2'});
|
table.insert( replacements, {'doors:door_wood_t_2', 'doors:door_'..v..'_t_2'});
|
||||||
|
@ -249,6 +265,21 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
-- table.insert( replacements, {'default:dirt_with_grass', dirt_with_grass_replacement });
|
-- table.insert( replacements, {'default:dirt_with_grass', dirt_with_grass_replacement });
|
||||||
table.insert( replacements, {'default:dirt', 'default:dirt_with_grass' });
|
table.insert( replacements, {'default:dirt', 'default:dirt_with_grass' });
|
||||||
|
|
||||||
|
-- realtest lacks quite a lot from default
|
||||||
|
if( mg_villages.realtest_trees ) then
|
||||||
|
for i=1,8 do
|
||||||
|
table.insert( replacements, {'farming:wheat_'..i, 'farming:spelt_'..tostring( math.floor( (i+0.5)/2 )) });
|
||||||
|
table.insert( replacements, {'farming:cotton_'..i, 'farming:flax_' ..tostring( math.floor( (i+0.5)/2 )) });
|
||||||
|
end
|
||||||
|
for i=1,5 do
|
||||||
|
table.insert( replacements, {'default:grass_'..i, 'air' });
|
||||||
|
end
|
||||||
|
table.insert( replacements, {'default:apple', 'air' });
|
||||||
|
table.insert( replacements, {'default:cobble', 'default:stone_macadam' });
|
||||||
|
table.insert( replacements, {'default:obsidian_glass', 'default:glass' });
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local wood_type = 'default:wood';
|
local wood_type = 'default:wood';
|
||||||
-- Taokis houses from structure i/o
|
-- Taokis houses from structure i/o
|
||||||
if( housetype == 'taoki' ) then
|
if( housetype == 'taoki' ) then
|
||||||
|
@ -310,7 +341,7 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
mg_villages.replace_materials( replacements, pr,
|
mg_villages.replace_materials( replacements, pr,
|
||||||
{'stonebrick'},
|
{'stonebrick'},
|
||||||
{'default:'},
|
{'default:'},
|
||||||
{'stonebrick', 'desert_stonebrick','sandstonebrick', 'sandstone','stone','desert_stone'},
|
{'stonebrick', 'desert_stonebrick','sandstonebrick', 'sandstone','stone','desert_stone','stone_flat','desert_stone_flat','stone_bricks','desert_strone_bricks'},
|
||||||
'stonebrick');
|
'stonebrick');
|
||||||
|
|
||||||
-- replace the wood as well
|
-- replace the wood as well
|
||||||
|
@ -322,7 +353,7 @@ mg_villages.get_replacement_list = function( housetype, pr )
|
||||||
mg_villages.replace_tree_trunk( replacements, wood_type );
|
mg_villages.replace_tree_trunk( replacements, wood_type );
|
||||||
mg_villages.replace_saplings( replacements, wood_type );
|
mg_villages.replace_saplings( replacements, wood_type );
|
||||||
|
|
||||||
if( pr:next(1,3)==1 ) then
|
if( pr:next(1,3)==1 and not( mg_villages.realtest_trees)) then
|
||||||
table.insert( replacements, {'default:glass', 'default:obsidian_glass'});
|
table.insert( replacements, {'default:glass', 'default:obsidian_glass'});
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -681,3 +712,15 @@ mg_villages.get_replacement_table = function( housetype, pr, replacements )
|
||||||
end
|
end
|
||||||
return { table = rtable, list = replacements, ids = ids };
|
return { table = rtable, list = replacements, ids = ids };
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mg_villages.get_content_id_replaced = function( node_name, replacements )
|
||||||
|
if( not( node_name ) or not( replacements ) or not(replacements.table )) then
|
||||||
|
return minetest.get_content_id( 'ignore' );
|
||||||
|
end
|
||||||
|
if( replacements.table[ node_name ]) then
|
||||||
|
return minetest.get_content_id( replacements.table[ node_name ] );
|
||||||
|
else
|
||||||
|
return minetest.get_content_id( node_name );
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
37
villages.lua
37
villages.lua
|
@ -865,6 +865,7 @@ local function generate_building(pos, minp, maxp, data, param2_data, a, pr, extr
|
||||||
or new_content == cid.c_chest_storage ) then
|
or new_content == cid.c_chest_storage ) then
|
||||||
-- we're dealing with a chest that might need filling
|
-- we're dealing with a chest that might need filling
|
||||||
table.insert( extra_calls.chests, {x=ax, y=ay, z=az, typ=new_content});
|
table.insert( extra_calls.chests, {x=ax, y=ay, z=az, typ=new_content});
|
||||||
|
-- TODO: perhaps use a locked chest owned by the mob living there?
|
||||||
-- place a normal chest here
|
-- place a normal chest here
|
||||||
data[a:index(ax, ay, az)] = cid.c_chest;
|
data[a:index(ax, ay, az)] = cid.c_chest;
|
||||||
|
|
||||||
|
@ -1069,6 +1070,7 @@ local function generate_walls(bpos, data, a, minp, maxp, vh, vx, vz, vs, vnoise)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- determine which building is to be placed where
|
-- determine which building is to be placed where
|
||||||
-- also choose which blocks to replace with which other blocks (to make villages more intresting)
|
-- also choose which blocks to replace with which other blocks (to make villages more intresting)
|
||||||
mg_villages.generate_village = function(village, vnoise)
|
mg_villages.generate_village = function(village, vnoise)
|
||||||
|
@ -1119,11 +1121,7 @@ mg_villages.generate_village = function(village, vnoise)
|
||||||
|
|
||||||
-- determine which plants will grow in the area around the village
|
-- determine which plants will grow in the area around the village
|
||||||
local plantlist = {};
|
local plantlist = {};
|
||||||
local sapling_id = replacements.table[ 'default:sapling' ];
|
sapling_id = mg_villages.get_content_id_replaced( 'default:sapling', replacements );
|
||||||
if( not( sapling_id )) then
|
|
||||||
sapling_id = 'default:sapling';
|
|
||||||
end
|
|
||||||
sapling_id = minetest.get_content_id( sapling_id );
|
|
||||||
-- 1/sapling_p = probability of a sapling beeing placed
|
-- 1/sapling_p = probability of a sapling beeing placed
|
||||||
local sapling_p = 25;
|
local sapling_p = 25;
|
||||||
if( mg_villages.sapling_probability[ sapling_id ] ) then
|
if( mg_villages.sapling_probability[ sapling_id ] ) then
|
||||||
|
@ -1132,37 +1130,25 @@ mg_villages.generate_village = function(village, vnoise)
|
||||||
|
|
||||||
-- medieval villages are sourrounded by wheat fields
|
-- medieval villages are sourrounded by wheat fields
|
||||||
if( village_type == 'medieval' ) then
|
if( village_type == 'medieval' ) then
|
||||||
local c_wheat = minetest.get_content_id( 'farming:wheat_8');
|
local c_wheat = mg_villages.get_content_id_replaced( 'farming:wheat_8', replacements);
|
||||||
if( mg_villages.realtest_trees ) then
|
|
||||||
c_wheat = minetest.get_content_id( 'farming:spelt_4');
|
|
||||||
end
|
|
||||||
plantlist = {
|
plantlist = {
|
||||||
{ id=sapling_id, p=sapling_p*10 }, -- trees are rather rare
|
{ id=sapling_id, p=sapling_p*10 }, -- trees are rather rare
|
||||||
{ id=c_wheat, p=1 }};
|
{ id=c_wheat, p=1 }};
|
||||||
-- lumberjack camps have handy trees nearby
|
-- lumberjack camps have handy trees nearby
|
||||||
elseif( village_type == 'lumberjack' ) then
|
elseif( village_type == 'lumberjack' ) then
|
||||||
local c_junglegrass = minetest.get_content_id( 'default:junglegrass');
|
local c_junglegrass = mg_villages.get_content_id_replaced( 'default:junglegrass', replacements);
|
||||||
if( mg_villages.realtest_trees ) then
|
|
||||||
c_wheat = minetest.get_content_id( 'default:dry_shrub');
|
|
||||||
end
|
|
||||||
plantlist = {
|
plantlist = {
|
||||||
{ id=sapling_id, p=sapling_p },
|
{ id=sapling_id, p=sapling_p },
|
||||||
{ id=c_junglegrass, p=25 }};
|
{ id=c_junglegrass, p=25 }};
|
||||||
-- the villages of type taoki grow cotton
|
-- the villages of type taoki grow cotton
|
||||||
elseif( village_type == 'taoki' ) then
|
elseif( village_type == 'taoki' ) then
|
||||||
local c_cotton = minetest.get_content_id( 'farming:cotton_8');
|
local c_cotton = mg_villages.get_content_id_replaced( 'farming:cotton_8', replacements);
|
||||||
if( mg_villages.realtest_trees ) then
|
|
||||||
c_wheat = minetest.get_content_id( 'farming:flax_4');
|
|
||||||
end
|
|
||||||
plantlist = {
|
plantlist = {
|
||||||
{ id=sapling_id, p=sapling_p*5 }, -- not too many trees
|
{ id=sapling_id, p=sapling_p*5 }, -- not too many trees
|
||||||
{ id=c_cotton, p=1 }};
|
{ id=c_cotton, p=1 }};
|
||||||
-- default/fallback: grassland
|
-- default/fallback: grassland
|
||||||
else
|
else
|
||||||
local c_grass = minetest.get_content_id( 'default:grass_5');
|
local c_grass = mg_villages.get_content_id_replaced( 'default:grass_5', replacements);
|
||||||
if( mg_villages.realtest_trees ) then
|
|
||||||
c_wheat = minetest.get_content_id( 'default:dry_shrub');
|
|
||||||
end
|
|
||||||
plantlist = {
|
plantlist = {
|
||||||
{ id=sapling_id, p=sapling_p*10}, -- only few trees
|
{ id=sapling_id, p=sapling_p*10}, -- only few trees
|
||||||
{ id=c_grass, p=3 }};
|
{ id=c_grass, p=3 }};
|
||||||
|
@ -1199,6 +1185,15 @@ mg_villages.place_buildings = function(village, minp, maxp, data, param2_data, a
|
||||||
|
|
||||||
local replacements = mg_villages.get_replacement_table( village.village_type, p, village.to_add_data.replacements );
|
local replacements = mg_villages.get_replacement_table( village.village_type, p, village.to_add_data.replacements );
|
||||||
|
|
||||||
|
cid.c_chest = mg_villages.get_content_id_replaced( 'default:chest', replacements );
|
||||||
|
cid.c_chest_locked = mg_villages.get_content_id_replaced( 'default:chest_locked', replacements );
|
||||||
|
cid.c_chest_private = mg_villages.get_content_id_replaced( 'cottages:chest_private', replacements );
|
||||||
|
cid.c_chest_work = mg_villages.get_content_id_replaced( 'cottages:chest_work', replacements );
|
||||||
|
cid.c_chest_storage = mg_villages.get_content_id_replaced( 'cottages:chest_storage', replacements );
|
||||||
|
cid.c_chest_shelf = mg_villages.get_content_id_replaced( 'cottages:shelf', replacements );
|
||||||
|
cid.c_sign = mg_villages.get_content_id_replaced( 'default:sign_wall', replacements );
|
||||||
|
print('REPLACEMENTS: '..minetest.serialize( replacements.table )..' CHEST: '..tostring( minetest.get_name_from_content_id( cid.c_chest ))); -- TODO
|
||||||
|
|
||||||
local extranodes = {}
|
local extranodes = {}
|
||||||
local extra_calls = { on_constr = {}, trees = {}, chests = {}, signs = {} };
|
local extra_calls = { on_constr = {}, trees = {}, chests = {}, signs = {} };
|
||||||
for _, pos in ipairs(bpos) do
|
for _, pos in ipairs(bpos) do
|
||||||
|
|
Loading…
Reference in New Issue