added better support for we files for build chest

This commit is contained in:
Sokomine 2015-04-18 01:45:05 +02:00
parent d9fe1c1b5c
commit 4ab4362d5f
2 changed files with 12 additions and 5 deletions

View File

@ -62,6 +62,7 @@ mg_villages.analyze_we_file = function(scm, we_origin)
scm[ent.y][ent.x][ent.z] = { nodenames_id[ ent.name ], ent.param2 }; --TODO ent.meta
end
local c_air = minetest.get_content_id("air")
for x = 1, maxx do
for y = 1, maxy do
@ -72,13 +73,14 @@ mg_villages.analyze_we_file = function(scm, we_origin)
if scm[y][x] == nil then
scm[y][x] = {}
end
if scm[y][x][z] == nil then
scm[y][x][z] = c_air
end
-- if scm[y][x][z] == nil then
-- scm[y][x][z] = c_air
-- end
end
end
end
local size = {};
size.y = #scm;
size.x = #scm[1];

View File

@ -78,7 +78,9 @@ build_chest.count_nodes = function( data )
else
id = a;
end
statistic[ id ] = { id, statistic[ id ][ 2 ]+1 };
if( statistic[ id ] and statistic[ id ][ 2 ] ) then
statistic[ id ] = { id, statistic[ id ][ 2 ]+1 };
end
end
end
end
@ -93,7 +95,10 @@ build_chest.read_building = function( building_name )
-- read data
local res = handle_schematics.analyze_mts_file( building_name );
if( not( res )) then
return;
res = mg_villages.analyze_we_file( building_name, nil );
if( not( res )) then
return;
end
end
build_chest.building[ building_name ].size = res.size;
build_chest.building[ building_name ].nodenames = res.nodenames;