provide a list of bed positions

master
Sokomine 2017-06-28 22:51:42 +02:00
parent 8c609aa0e3
commit d6b998f4ab
3 changed files with 8 additions and 2 deletions

View File

@ -138,6 +138,7 @@ handle_schematics.analyze_mts_file = function( path )
-- some mods (like mg_villages) might be intrested in the number of npc that can live here
local bed_count = 0;
local bed_list = {};
local p2offset = (size.x*size.y*size.z)*3;
local i = 1;
@ -160,6 +161,7 @@ handle_schematics.analyze_mts_file = function( path )
scm[y][x][z] = {id, p2};
if( handle_schematics.bed_node_names[ nodenames[ id ]]) then
bed_count = bed_count + 1;
table.insert( bed_list, {x=x, y=y, z=z, p2, id});
end
end
end
@ -167,7 +169,7 @@ handle_schematics.analyze_mts_file = function( path )
end
--print( "MTS FILE "..tostring(path)..": "..tostring( bed_count ).." beds.");
return { size = { x=size.x, y=size.y, z=size.z}, nodenames = nodenames, on_constr = on_constr, after_place_node = after_place_node, rotated=rotated, burried=burried, scm_data_cache = scm, bed_count = bed_count };
return { size = { x=size.x, y=size.y, z=size.z}, nodenames = nodenames, on_constr = on_constr, after_place_node = after_place_node, rotated=rotated, burried=burried, scm_data_cache = scm, bed_count = bed_count, bed_list = bed_list };
end

View File

@ -29,6 +29,7 @@ handle_schematics.analyze_we_file = function(scm, we_origin)
end
local bed_count = 0;
local bed_list = {};
scm = {}
local maxx, maxy, maxz = -1, -1, -1
@ -79,6 +80,7 @@ handle_schematics.analyze_we_file = function(scm, we_origin)
scm[ent.y][ent.x][ent.z] = { nodenames_id[ ent.name ], ent.param2 };
if( handle_schematics.bed_node_names[ ent.name ]) then
bed_count = bed_count + 1;
table.insert( bed_list, {x=x, y=y, z=z, p2, id});
end
end
@ -99,5 +101,5 @@ handle_schematics.analyze_we_file = function(scm, we_origin)
size.x = math.max(maxx,0);
size.z = math.max(maxz,0);
return { size = { x=size.x, y=size.y, z=size.z}, nodenames = nodenames, on_constr = {}, after_place_node = {}, rotated=0, burried=0, scm_data_cache = scm, metadata = all_meta, bed_count = bed_count };
return { size = { x=size.x, y=size.y, z=size.z}, nodenames = nodenames, on_constr = {}, after_place_node = {}, rotated=0, burried=0, scm_data_cache = scm, metadata = all_meta, bed_count = bed_count, bed_list = bed_list };
end

View File

@ -69,6 +69,8 @@ build_chest.read_building = function( building_name )
build_chest.building[ building_name ].burried = res.burried;
build_chest.building[ building_name ].metadata = res.metadata;
build_chest.building[ building_name ].bed_count = res.bed_count;
-- mobs are very intrested in beds in which they might sleep at night
build_chest.building[ building_name ].bed_list = res.bed_list;
-- scm_data_cache is not stored as that would take up too much storage space
--build_chest.building[ building_name ].scm_data_cache = res.scm_data_cache;