list entrances in plotmarker formspec
This commit is contained in:
parent
7373da1f88
commit
e7a67e3155
@ -370,6 +370,8 @@ mg_villages.add_building = function( building_data )
|
||||
-- the above function - provided they are not part of path_info yet;
|
||||
-- the information stored in path_info is the relevant one for mob movement/pathfinding
|
||||
|
||||
-- store the front doors in extra list
|
||||
building_data.front_door_list = {};
|
||||
-- gain the list of beds from path_info data
|
||||
building_data.bed_list = {};
|
||||
-- mobs are seldom able to stand directly on or even next to the bed when getting up
|
||||
@ -379,6 +381,7 @@ mg_villages.add_building = function( building_data )
|
||||
and mg_villages.path_info[ building_data.short_file_name ] ) then
|
||||
local paths = mg_villages.path_info[ building_data.short_file_name];
|
||||
if( paths and paths[1] ) then
|
||||
-- iterate over all bed-to-first-front-door-paths (we want to identify beds)
|
||||
for i,p in ipairs( paths[1] ) do
|
||||
-- the last entry has a diffrent meaning
|
||||
if( p and p[1] and i<#paths[1]) then
|
||||
@ -390,6 +393,17 @@ mg_villages.add_building = function( building_data )
|
||||
end
|
||||
end
|
||||
end
|
||||
-- iterate over all paths and take a look at the first bed only (we want to
|
||||
-- get the doors now, not the beds)
|
||||
for i,p in ipairs( paths ) do
|
||||
-- paths[i]: paths from all beds to front door i
|
||||
-- paths[i][1]: path from first bed to front door i
|
||||
if( p and p[1] ) then
|
||||
-- the place in front of the door is the last entry
|
||||
local d = p[1][ #p[1]];
|
||||
building_data.front_door_list[i] = {d[1],d[2],d[3]};
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
-- make sure this refers to the same data as building_data.bed_list
|
||||
@ -407,10 +421,18 @@ mg_villages.add_building = function( building_data )
|
||||
building_data.workplace_list[i] = {p[1][1],p[1][2],p[1][3],p[1][4]};
|
||||
end
|
||||
end
|
||||
-- no front doors found through beds? then take a look if the workplaces found doors
|
||||
if( #building_data.front_door_list < 1 ) then
|
||||
for i,p in ipairs( paths ) do
|
||||
if( p and p[1] ) then
|
||||
local d = p[1][ #p[1]];
|
||||
building_data.front_door_list[i] = {d[1],d[2],d[3]};
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- missing data regarding building size - do not use this building for anything
|
||||
elseif( not( building_data.sizex ) or not( building_data.sizez )
|
||||
or building_data.sizex == 0 or building_data.sizez==0) then
|
||||
|
@ -552,6 +552,16 @@ mg_villages.inhabitants.print_house_info = function( village_to_add_data_bpos, h
|
||||
mg_villages.inhabitants.print_plot_list(village_to_add_data_bpos, bpos.beds[1].owns)..".";
|
||||
end
|
||||
end
|
||||
-- which entrances/front doors does the building have?
|
||||
local front_doors = mg_villages.inhabitants.get_front_doors(bpos);
|
||||
local door_str = "Entrances: ";
|
||||
for i,p in ipairs( front_doors ) do
|
||||
door_str = door_str..minetest.pos_to_string( p ).." ";
|
||||
end
|
||||
if( not( front_doors ) or #front_doors<1) then
|
||||
door_str = door_str.."- unknown -";
|
||||
end
|
||||
|
||||
if( people_str == "" ) then
|
||||
people_str = "- nobody lives or works here permanently -";
|
||||
end
|
||||
@ -587,6 +597,7 @@ mg_villages.inhabitants.print_house_info = function( village_to_add_data_bpos, h
|
||||
prev_next_button..
|
||||
'label[0.5,0.5;'..minetest.formspec_escape(str)..']'..
|
||||
'label[0.5,4.1;'..add_str..']'..
|
||||
'label[0.5,4.6;'..minetest.formspec_escape(door_str)..']'..
|
||||
'tablecolumns[' ..
|
||||
'text,align=left]'.. -- name and description of inhabitant
|
||||
'table[0.1,1.0;11.4,3.0;mg_villages:formspec_list_inhabitants;'..people_str..']';
|
||||
@ -1329,6 +1340,23 @@ mg_villages.inhabitants.prepare_metadata = function( village, village_id, minp,
|
||||
end
|
||||
|
||||
|
||||
-- determine positions of front doors from stored pathinfo data and building_data.front_door_list
|
||||
mg_villages.inhabitants.get_front_doors = function( bpos )
|
||||
if( not( bpos ) or not( bpos.btype ) or not( mg_villages.BUILDINGS[ bpos.btype ] )) then
|
||||
return {};
|
||||
end
|
||||
local building_data = mg_villages.BUILDINGS[ bpos.btype ];
|
||||
if( not( building_data ) or not( building_data.front_door_list )) then
|
||||
return {};
|
||||
end
|
||||
local door_list = {};
|
||||
for i,d in ipairs( building_data.front_door_list ) do
|
||||
door_list[i] = mg_villages.transform_coordinates( {d[1],d[2],d[3]}, bpos);
|
||||
end
|
||||
return door_list;
|
||||
end
|
||||
|
||||
|
||||
-- spawn mobs in villages
|
||||
mg_villages.inhabitants.part_of_village_spawned = function( village, minp, maxp, data, param2_data, a, cid )
|
||||
-- for each building in the village
|
||||
|
Loading…
x
Reference in New Issue
Block a user