take care of aliases when storing information about weather a node is ground or not

master
Sokomine 2020-04-08 02:23:02 +02:00
parent da1fa63687
commit 5a3b8b548f
3 changed files with 20 additions and 15 deletions

View File

@ -89,14 +89,7 @@ replacements_group['farming'].add_material = function( fruit, fruit_item, prefix
replacements_group['farming'].data[ fruit_item ] = data;
-- farming nodes do not count as ground (except for soil - which is not handled here)
local c_ignore = minetest.get_content_id( 'ignore' );
for _,v in ipairs( data ) do
local id = minetest.get_content_id( v );
if( id and id ~= c_ignore ) then
replacements_group.node_is_ground[ id ] = false;
end
end
handle_schematics.set_node_is_ground(data, false);
if( is_loaded and minetest.get_modpath('mobf_trader') and mobf_trader and mobf_trader.add_trader ) then

View File

@ -116,6 +116,24 @@ handle_schematics.replace_randomized = function( replacements, new_materials )
end
handle_schematics.set_node_is_ground = function(data, value)
local c_ignore = minetest.get_content_id( 'ignore' );
-- none of the nodes in the data table count as ground
for _,v in ipairs( data ) do
local real_name = minetest.registered_aliases[ v ];
if(not(real_name)) then
real_name = v;
end
if(real_name and real_name ~= "" and minetest.registered_nodes[ real_name ]) then
local id = minetest.get_content_id( real_name );
if( id and id ~= c_ignore ) then
replacements_group.node_is_ground[ id ] = value;
end
end
end
end
-- just some examples for testing:
--handle_schematics.global_replacement_table[ 'default:wood' ] = 'default:mese';
--handle_schematics.global_replacement_table[ 'stairs:stair_wood' ] = 'default:diamondblock';

View File

@ -150,13 +150,7 @@ replacements_group['wood'].add_material = function( candidate_list, mod_prefix,
replacements_group['wood'].data[ wood_name ] = data;
-- none of the wood nodes counts as ground
local c_ignore = minetest.get_content_id( 'ignore' );
for _,v in ipairs( data ) do
local id = minetest.get_content_id( v );
if( id and id ~= c_ignore ) then
replacements_group.node_is_ground[ id ] = false;
end
end
handle_schematics.set_node_is_ground(data, false);
if( is_loaded and minetest.get_modpath('mobf_trader') and mobf_trader and mobf_trader.add_trader ) then
-- TODO: check if all offered payments exist