cleaned up and added comments
This commit is contained in:
parent
f28be93939
commit
4f77725877
@ -1,5 +1,3 @@
|
||||
settrustees = 0
|
||||
|
||||
-- get the id of the village pos lies in (or nil if outside of villages)
|
||||
mg_villages.get_town_id_at_pos = function( pos )
|
||||
for id, v in pairs( mg_villages.all_villages ) do
|
||||
@ -143,9 +141,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
"label[2.5,0.5;Building:]"..
|
||||
"label[3.5,0.5;"..tostring( mg_villages.BUILDINGS[btype].scm ).."]"..
|
||||
"field[20,20;0.1,0.1;pos2str;Pos;"..minetest.pos_to_string( pos ).."]";
|
||||
if settrustees == 0 then
|
||||
local formspec = "";
|
||||
end
|
||||
local ifinhabit = "";
|
||||
|
||||
-- Get Price
|
||||
@ -159,7 +155,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
elseif (mg_villages.BUILDINGS[btype].typ and mg_villages.prices[ mg_villages.BUILDINGS[btype].typ ]) then
|
||||
price = mg_villages.prices[ mg_villages.BUILDINGS[btype].typ ];
|
||||
end
|
||||
|
||||
-- Get if is inhabitant house
|
||||
if (mg_villages.BUILDINGS[btype].inh and mg_villages.BUILDINGS[btype].inh > 0 ) then
|
||||
ifinhabit = "label[1,1.5;Owners of this plot count as village inhabitants.]";
|
||||
end
|
||||
@ -181,14 +177,17 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
|
||||
-- On Press buy button
|
||||
if (fields['buy']) then
|
||||
-- check if the price can be paid
|
||||
local inv = player:get_inventory();
|
||||
|
||||
if not mg_villages.all_villages[village_id].ownerlist then
|
||||
mg_villages.all_villages[village_id].ownerlist = {}
|
||||
end
|
||||
|
||||
-- Check if player already has a house in the village
|
||||
if mg_villages.all_villages[village_id].ownerlist[pname] then
|
||||
formspec = formspec.."label[1,1.9;Sorry. You already have a plot in this village.]";
|
||||
|
||||
-- Check if the price can be paid
|
||||
elseif( inv and inv:contains_item( 'main', price_stack )) then
|
||||
formspec = original_formspec..
|
||||
"label[1,1;Congratulations! You have bought this plot.]"..
|
||||
@ -212,6 +211,7 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
-- If player is the owner of the plot
|
||||
elseif (owner==pname) then
|
||||
|
||||
-- Check if inhabitant house
|
||||
if(btype ~= 'road'
|
||||
and mg_villages.BUILDINGS[btype]
|
||||
and mg_villages.BUILDINGS[btype].inh
|
||||
@ -244,7 +244,6 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
|
||||
-- If Player wants to add/remove trusted players
|
||||
if (fields['add_remove']) then
|
||||
settrustees = 1
|
||||
local previousTrustees = mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit
|
||||
local output = "";
|
||||
if previousTrustees == nil then
|
||||
@ -264,7 +263,6 @@ mg_villages.plotmarker_formspec = function( pos, formname, fields, player )
|
||||
|
||||
-- Save trusted players
|
||||
if (fields["savetrustees"] == "Save") then
|
||||
settrustees = 0;
|
||||
|
||||
if not mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit then
|
||||
mg_villages.all_villages[ village_id ].to_add_data.bpos[ plot_nr ].can_edit = {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user