ensure that global replacements are applied
parent
2f11935b97
commit
80aece31bb
|
@ -570,8 +570,8 @@ build_chest.update_formspec = function( pos, page, player, fields )
|
|||
-- do replacements for realtest where necessary (this needs to be done only once)
|
||||
local replacements = {};
|
||||
replacements_group['realtest'].replace( replacements );
|
||||
-- do replacements for nodes that no longer exist
|
||||
replacements_group['discontinued_nodes'].replace( replacements );
|
||||
-- do replacements for nodes that no longer exist and other global replacements
|
||||
handle_schematics.apply_global_replacements(replacements, build_chest.building[ options[1]].nodenames)
|
||||
meta:set_string( 'replacements', minetest.serialize( replacements ));
|
||||
|
||||
-- allow changes to be made
|
||||
|
|
|
@ -1,42 +1,11 @@
|
|||
replacements_group['discontinued_nodes'] = {}
|
||||
|
||||
replacements_group['discontinued_nodes'].doors = function( repl, door_type)
|
||||
if( not( door_type )) then
|
||||
return repl;
|
||||
end
|
||||
-- doors went through a lot of changes in the past
|
||||
local door_types = {'wood', 'steel', 'glass', 'obsidian'}
|
||||
for i, door_typ in ipairs(door_types) do
|
||||
local door_name = 'doors:door_'..door_typ
|
||||
-- the upper part is no longer a seperate part
|
||||
table.insert( repl, {'doors:door_'..door_type..'_t_1', 'doors:hidden'});
|
||||
table.insert( repl, {'doors:door_'..door_type..'_t_2', 'doors:hidden'});
|
||||
handle_schematics.global_replacement_table[ door_name..'_t_1' ] = 'doors:hidden'
|
||||
handle_schematics.global_replacement_table[ door_name..'_t_2' ] = 'doors:hidden'
|
||||
-- the lower part is now two nodes high
|
||||
table.insert( repl, {'doors:door_'..door_type..'_b_1', 'doors:door_'..door_type..'_a'});
|
||||
table.insert( repl, {'doors:door_'..door_type..'_b_2', 'doors:door_'..door_type..'_b'});
|
||||
return repl;
|
||||
handle_schematics.global_replacement_table[ door_name..'_b_1' ] = door_name..'_a'
|
||||
handle_schematics.global_replacement_table[ door_name..'_b_2' ] = door_name..'_b'
|
||||
end
|
||||
|
||||
replacements_group['discontinued_nodes'].replace = function( replacements )
|
||||
|
||||
local repl = {};
|
||||
|
||||
-- doors changed from two nodes for a door to one two-node-high mesh
|
||||
replacements_group['discontinued_nodes'].doors( repl, 'wood' );
|
||||
replacements_group['discontinued_nodes'].doors( repl, 'steel' );
|
||||
replacements_group['discontinued_nodes'].doors( repl, 'glass' );
|
||||
replacements_group['discontinued_nodes'].doors( repl, 'obsidian_glass');
|
||||
|
||||
for i,v in ipairs( repl ) do
|
||||
if( v and v[2] and handle_schematics.node_defined( v[2]) ) then
|
||||
local found = false;
|
||||
for j,w in ipairs( replacements ) do
|
||||
if( w and w[1] and w[1]==v[1] ) then
|
||||
w[2] = v[2];
|
||||
found = true;
|
||||
end
|
||||
end
|
||||
if( not( found )) then
|
||||
table.insert( replacements, {v[1],v[2]} );
|
||||
end
|
||||
end
|
||||
end
|
||||
return replacements;
|
||||
end
|
||||
|
||||
|
|
|
@ -30,6 +30,34 @@ handle_schematics.node_defined = function( node_name )
|
|||
end
|
||||
|
||||
|
||||
-- this is mostly for the build chest so that the final material beeing used can be shown
|
||||
handle_schematics.apply_global_replacements = function(replacements, nodenames)
|
||||
-- change existing replacements where needed
|
||||
for i, repl in ipairs(replacements) do
|
||||
if(handle_schematics.global_replacement_table[ repl[2] ]) then
|
||||
replacements[i][2] = handle_schematics.global_replacement_table[ repl[2] ]
|
||||
end
|
||||
end
|
||||
-- add replacement for nodenames that are not yet covered
|
||||
for k, name in ipairs(nodenames) do
|
||||
-- if the node is to be replaced
|
||||
if(handle_schematics.global_replacement_table[name]) then
|
||||
local found = false
|
||||
for i, repl in ipairs(replacements) do
|
||||
if(repl[1] == name) then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if(not(found)) then
|
||||
table.insert(replacements, {name, handle_schematics.global_replacement_table[name]})
|
||||
end
|
||||
end
|
||||
end
|
||||
return replacements
|
||||
end
|
||||
|
||||
|
||||
-- applies all necessary replacements:
|
||||
-- * discontinued chests from cottages
|
||||
-- * changed nodes in minetest_game such as doors etc.
|
||||
|
@ -39,6 +67,7 @@ end
|
|||
-- new_materials. If new_materials is empty, random replacements will used.
|
||||
-- Structure of new_materials = {"wood":new_wood_material,
|
||||
-- "roof":new_roof_material, "farming":new_cotton_replacement}
|
||||
-- (currently only used by handle_schematics/detect_flat_land_fast.lua)
|
||||
handle_schematics.replace_randomized = function( replacements, new_materials )
|
||||
|
||||
if( not( replacements )) then
|
||||
|
@ -52,9 +81,6 @@ handle_schematics.replace_randomized = function( replacements, new_materials )
|
|||
table.insert( replacements, {"cottages:chest_work", "default:chest"});
|
||||
table.insert( replacements, {"cottages:chest_storage", "default:chest"});
|
||||
|
||||
-- change old doors and other nodes that havve been changed to new ones
|
||||
replacements = replacements_group['discontinued_nodes'].replace( replacements );
|
||||
|
||||
-- replace the wood
|
||||
if( not(new_materials['wood']) or not( minetest.registered_nodes[ new_materials['wood'] ])) then
|
||||
new_materials['wood'] = replacements_group['wood'].found[
|
||||
|
|
Loading…
Reference in New Issue