added roof types
This commit is contained in:
parent
0fb1a15841
commit
5108701c08
@ -209,6 +209,7 @@ build_chest.get_replacement_list_formspec = function( pos, selected_row )
|
||||
-- there may be wood types that only occour as stairs and/or slabs etc., without full blocks
|
||||
local types_found_list_wood = {};
|
||||
local types_found_list_farming = {};
|
||||
local types_found_list_roof = {};
|
||||
|
||||
for i,v in ipairs( build_chest.building[ building_name ].statistic ) do
|
||||
local name = build_chest.building[ building_name ].nodenames[ v[1]];
|
||||
@ -255,6 +256,7 @@ build_chest.get_replacement_list_formspec = function( pos, selected_row )
|
||||
|
||||
extra_buttons = build_chest.get_replacement_extra_buttons( 'wood', name, types_found_list_wood, 'set_wood', extra_buttons );
|
||||
extra_buttons = build_chest.get_replacement_extra_buttons( 'farming', name, types_found_list_farming, 'set_farming', extra_buttons );
|
||||
extra_buttons = build_chest.get_replacement_extra_buttons( 'roof', name, types_found_list_farming, 'set_roof', extra_buttons );
|
||||
|
||||
j=j+1;
|
||||
end
|
||||
@ -925,6 +927,15 @@ build_chest.update_formspec = function( pos, page, player )
|
||||
return;
|
||||
end
|
||||
|
||||
local set_roof = meta:get_string('set_roof' );
|
||||
if( set_roof and set_roof ~= "" ) then
|
||||
formspec = formspec..
|
||||
"label[1,2.5;Select a roof type for the house:]"..
|
||||
build_chest.get_group_list_formspec( pos, 'roof', 'roof_selection' );
|
||||
meta:set_string('formspec', formspec );
|
||||
return;
|
||||
end
|
||||
|
||||
if( building_name and building_name ~= '' and start_pos and start_pos ~= '' and meta:get_string('replacements')) then
|
||||
formspec = formspec..build_chest.get_replacement_list_formspec( pos );
|
||||
meta:set_string('formspec', formspec );
|
||||
@ -1248,7 +1259,8 @@ build_chest.on_receive_fields = function(pos, formname, fields, player)
|
||||
meta:set_string( 'current_path', minetest.serialize( current_path ));
|
||||
meta:set_string( 'building_name', '');
|
||||
meta:set_string( 'set_wood', '');
|
||||
meta:set_string( 'set_farming', '');
|
||||
meta:set_string( 'set_farming', '');
|
||||
meta:set_string( 'set_roof', '');
|
||||
meta:set_int( 'replace_row', 0 );
|
||||
meta:set_int( 'page_nr', 0 );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
@ -1303,24 +1315,31 @@ build_chest.on_receive_fields = function(pos, formname, fields, player)
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
|
||||
elseif( fields.wood_selection ) then
|
||||
build_chest.apply_replacement_for_group( pos, meta, 'wood', fields.wood_selection, 'set_wood' );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
|
||||
elseif( fields.set_wood ) then
|
||||
meta:set_string('set_wood', fields.set_wood );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
|
||||
elseif( fields.set_farming ) then
|
||||
meta:set_string('set_farming', fields.set_farming );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
elseif( fields.set_roof ) then
|
||||
meta:set_string('set_roof', fields.set_roof );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
|
||||
elseif( fields.wood_selection ) then
|
||||
build_chest.apply_replacement_for_group( pos, meta, 'wood', fields.wood_selection, 'set_wood' );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
elseif( fields.farming_selection ) then
|
||||
build_chest.apply_replacement_for_group( pos, meta, 'farming', fields.farming_selection, 'set_farming' );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
elseif( fields.roof_selection ) then
|
||||
build_chest.apply_replacement_for_group( pos, meta, 'roof', fields.roof_selection, 'set_roof' );
|
||||
build_chest.update_formspec( pos, 'main', player );
|
||||
|
||||
|
||||
elseif( fields.proceed_with_scaffolding ) then
|
||||
local building_name = meta:get_string('building_name');
|
||||
|
||||
1
init.lua
1
init.lua
@ -47,6 +47,7 @@ replacements_group = {};
|
||||
dofile(mg_villages.modpath.."/replacements_wood.lua")
|
||||
dofile(mg_villages.modpath.."/replacements_realtest.lua")
|
||||
dofile(mg_villages.modpath.."/replacements_farming.lua")
|
||||
dofile(mg_villages.modpath.."/replacements_roof.lua")
|
||||
dofile(mg_villages.modpath.."/replacements.lua")
|
||||
|
||||
-- multiple diffrent village types with their own sets of houses are supported
|
||||
|
||||
110
replacements_roof.lua
Normal file
110
replacements_roof.lua
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
replacements_group['roof'] = {}
|
||||
|
||||
-- this contains a list of all found/available nodenames that may act as a replacement frming nodes
|
||||
replacements_group['roof'].found = {};
|
||||
-- contains a list of *all* known roof names - even of mods that may not be installed
|
||||
replacements_group['roof'].all = {};
|
||||
|
||||
-- contains information about how a particular node is called if a particular roof mod is used;
|
||||
replacements_group['roof'].data = {};
|
||||
|
||||
|
||||
replacements_group['roof'].replace_material = function( replacements, old_material, new_material )
|
||||
|
||||
if( not( old_material ) or not( replacements_group['roof'].data[ old_material ])
|
||||
or not( new_material ) or not( replacements_group['roof'].data[ new_material ])
|
||||
or old_material == new_material ) then
|
||||
return replacements;
|
||||
end
|
||||
|
||||
local old_nodes = replacements_group['roof'].data[ old_material ];
|
||||
local new_nodes = replacements_group['roof'].data[ new_material ];
|
||||
for i=1,#old_nodes do
|
||||
local old = old_nodes[i];
|
||||
local new = old;
|
||||
if( i<=#new_nodes and new_nodes[i] and minetest.registered_nodes[ new_nodes[i]] ) then
|
||||
new = new_nodes[i];
|
||||
local found = false;
|
||||
for i,v in ipairs(replacements) do
|
||||
if( v and v[1]==old ) then
|
||||
v[2] = new;
|
||||
found = true;
|
||||
end
|
||||
end
|
||||
if( not( found )) then
|
||||
table.insert( replacements, { old, new });
|
||||
end
|
||||
end
|
||||
end
|
||||
return replacements;
|
||||
end
|
||||
|
||||
|
||||
---------------------
|
||||
-- internal functions
|
||||
---------------------
|
||||
replacements_group['roof'].add_material = function( nodelist )
|
||||
|
||||
local is_loaded = false;
|
||||
if( minetest.registered_items[ nodelist[1] ] ) then
|
||||
is_loaded = true;
|
||||
table.insert( replacements_group['roof'].found, nodelist[1] );
|
||||
end
|
||||
table.insert( replacements_group['roof'].all, nodelist[1]);
|
||||
|
||||
replacements_group['roof'].data[ nodelist[1] ] = nodelist;
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- create a list of all available fruit types
|
||||
replacements_group['roof'].construct_roof_type_list = function()
|
||||
|
||||
-- roof from cottages
|
||||
local roofs = {'straw', 'reet', 'wood', 'slate', 'red', 'brown', 'black'};
|
||||
for i,v in ipairs( roofs ) do
|
||||
replacements_group['roof'].add_material( {
|
||||
'cottages:roof_connector_'..v,
|
||||
'cottages:roof_flat_'..v,
|
||||
'', -- no full block available
|
||||
'cottages:roof_'..v
|
||||
} );
|
||||
end
|
||||
|
||||
|
||||
-- from dryplants
|
||||
roofs = {'reed', 'wetreed'};
|
||||
for i,v in ipairs( roofs ) do
|
||||
replacements_group['roof'].add_material( {
|
||||
'dryplants:'..v..'_roof',
|
||||
'dryplants:'..v..'_slab',
|
||||
'dryplants:'..v,
|
||||
'dryplants:'..v..'_roof',
|
||||
'dryplants:'..v..'_roof_corner',
|
||||
'dryplants:'..v..'_roof_corner_2'
|
||||
} );
|
||||
end
|
||||
-- roof from homedecor
|
||||
roofs = {'wood', 'terracootta', 'asphalt', 'glass'};
|
||||
for i,v in ipairs( roofs ) do
|
||||
replacements_group['roof'].add_material( {
|
||||
'homedecor:shingle_side_'..v,
|
||||
'homedecor:shingles_'..v,
|
||||
'',
|
||||
'homedecor:shingles_'..v,
|
||||
'homedecor:shingle_inner_corner_'..v,
|
||||
'homedecor:shingle_outer_corner_'..v,
|
||||
} );
|
||||
end
|
||||
|
||||
replacements_group['roof'].data[ 'homedecor:shingle_side_glass' ][2] = 'homedecor:skylight';
|
||||
replacements_group['roof'].data[ 'homedecor:shingle_side_glass' ][4] = 'homedecor:skylight';
|
||||
replacements_group['roof'].data[ 'homedecor:shingle_side_asphalt'][3] = 'streets:asphalt';
|
||||
|
||||
-- TODO: slopes from technic or other slopes mods?
|
||||
end
|
||||
|
||||
-- create the list of known roof fruits
|
||||
replacements_group['roof'].construct_roof_type_list();
|
||||
Loading…
Reference in New Issue
Block a user