added back buttons in list of inhabitants and plots
This commit is contained in:
parent
9232300570
commit
59b3a02598
@ -18,7 +18,8 @@ mg_villages.list_plots_formspec = function( player, formname, fields )
|
||||
|
||||
local formspec = 'size[12,12]'..
|
||||
'field[20,20;0.1,0.1;village_id;VillageID;'..minetest.formspec_escape( fields.village_id ).."]"..
|
||||
'button_exit[4.0,1.0;2,0.5;quit;Quit]'..
|
||||
'button_exit[4.0,1.0;2,0.5;quit;Exit]'..
|
||||
'button[9.5,1.0;3,0.5;back_to_villagelist;Back to village list]'..
|
||||
'tablecolumns[' ..
|
||||
'text,align=right;'.. -- plot nr
|
||||
'text,align=center;'.. -- type of building
|
||||
@ -59,7 +60,6 @@ mg_villages.list_plots_formspec = function( player, formname, fields )
|
||||
formspec = formspec.."owned by "..minetest.formspec_escape(" [plot "..tostring( bpos.belongs_to )..']')..',';
|
||||
end
|
||||
elseif( bpos.btype == "road" ) then
|
||||
print("ROAD on plot "..tostring( plot_nr )..": "..minetest.serialize( bpos ));
|
||||
if( not( bpos.parent_road_plot )) then
|
||||
formspec = formspec..'-,-,-,road stump,';
|
||||
elseif( bpos.parent_road_plot==0 ) then
|
||||
|
@ -495,7 +495,10 @@ mg_villages.inhabitants.print_house_info = function( village_to_add_data_bpos, h
|
||||
people_str = "- nobody lives or works here permanently -";
|
||||
end
|
||||
return 'size[12,4.5]'..
|
||||
'button_exit[9.5,0;2,0.5;back;Back]'..
|
||||
'button_exit[4.0,0;2,0.5;quit;Exit]'..
|
||||
'button[9.5,0;2,0.5;back_to_plotlist;Back to plotlist]'..
|
||||
-- the back button needs to know which village we are in
|
||||
'field[20,20;0.1,0.1;village_id;VillageID;'..minetest.formspec_escape( village_id ).."]"..
|
||||
'label[0.5,0.5;'..minetest.formspec_escape(str)..']'..
|
||||
'label[0.5,4.1;'..minetest.formspec_escape(add_str)..']'..
|
||||
'tablecolumns[' ..
|
||||
|
@ -51,7 +51,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
-- show a list of who lives (or works) here at this plot
|
||||
if( fields and fields.inhabitants ) then
|
||||
minetest.show_formspec( pname, "mg_villages:plot_mob_list",
|
||||
mg_villages.inhabitants.print_house_info( village.to_add_data.bpos, plot_nr ));
|
||||
mg_villages.inhabitants.print_house_info( village.to_add_data.bpos, plot_nr, village_id ));
|
||||
--mg_villages.debug_inhabitants( village, plot_nr);
|
||||
return;
|
||||
end
|
||||
@ -359,7 +359,8 @@ mg_villages.form_input_handler = function( player, formname, fields)
|
||||
end
|
||||
|
||||
-- provide information about the inhabitants of a particular plot
|
||||
if( fields['mg_villages:list_plots']
|
||||
if( not( fields['back_to_plotlist'])
|
||||
and fields['mg_villages:list_plots']
|
||||
and fields['mg_villages:list_plots']~=""
|
||||
and fields['village_id']) then
|
||||
local selection = minetest.explode_table_event( fields['mg_villages:list_plots'] );
|
||||
@ -372,13 +373,24 @@ mg_villages.form_input_handler = function( player, formname, fields)
|
||||
local village = mg_villages.all_villages[ fields.village_id ];
|
||||
local plot_nr = selection.row-1;
|
||||
minetest.show_formspec( pname, "mg_villages:plot_mob_list",
|
||||
mg_villages.inhabitants.print_house_info( village.to_add_data.bpos, plot_nr ));
|
||||
mg_villages.inhabitants.print_house_info( village.to_add_data.bpos, plot_nr, fields.village_id ));
|
||||
return true;
|
||||
end
|
||||
end
|
||||
|
||||
-- back from the list of inhabitants of a plot to the list of plots of a village
|
||||
if( fields['back_to_plotlist']
|
||||
and fields.village_id
|
||||
and mg_villages.all_villages[ fields.village_id ]) then
|
||||
-- show the player a list of plots of the selected village
|
||||
mg_villages.list_plots_formspec( player, 'mg_villages:list_plots', fields );
|
||||
return true;
|
||||
end
|
||||
|
||||
-- the player has selected a village in the village list
|
||||
if( fields['mg_villages:village_list'] and fields['mg_villages:village_list']~="") then
|
||||
if( not( fields['back_to_villagelist'])
|
||||
and fields['mg_villages:village_list']
|
||||
and fields['mg_villages:village_list']~="") then
|
||||
local selection = minetest.explode_table_event( fields['mg_villages:village_list'] );
|
||||
local pname = player:get_player_name();
|
||||
if( selection and selection.row
|
||||
@ -393,6 +405,13 @@ mg_villages.form_input_handler = function( player, formname, fields)
|
||||
end
|
||||
end
|
||||
|
||||
-- back from plotlist of a village to the list of nearby villages
|
||||
if( fields['back_to_villagelist']) then
|
||||
mg_villages.list_villages_formspec( player, "mg_villages:village_list", {});
|
||||
|
||||
return true;
|
||||
end
|
||||
|
||||
if( (formname == "mg_villages:plotmarker") and fields.pos2str and not( fields.abort )) then
|
||||
local pos = minetest.string_to_pos( fields.pos2str );
|
||||
mg_villages.plotmarker_formspec( pos, formname, fields, player );
|
||||
|
Loading…
x
Reference in New Issue
Block a user