@@ -32,7 +32,7 @@ function table_delete(t, e)
3232 return removed
3333end
3434
35- simple_protection .can_access = function (pos , player_name )
35+ s_protect .can_access = function (pos , player_name )
3636 if not player_name or player_name == " " then
3737 return false
3838 end
@@ -42,21 +42,21 @@ simple_protection.can_access = function(pos, player_name)
4242 end
4343
4444 -- Data of current area
45- local data = simple_protection .get_data (pos )
45+ local data = s_protect .get_data (pos )
4646
4747 -- Area is not claimed
4848 if not data then
4949 -- Allow digging when claiming is not forced
50- if not simple_protection .claim_to_dig then
50+ if not s_protect .claim_to_dig then
5151 return true
5252 end
5353
5454 -- Claim everywhere? Disallow everywhere.
55- if simple_protection .underground_claim then
55+ if s_protect .underground_claim then
5656 return false
5757 end
5858 -- Is it in claimable area? Yes? Disallow.
59- if pos .y >= simple_protection .underground_limit then
59+ if pos .y >= s_protect .underground_limit then
6060 return false
6161 end
6262 return true
@@ -65,7 +65,7 @@ simple_protection.can_access = function(pos, player_name)
6565 return true
6666 end
6767 -- Owner shared the area with the player
68- if table_contains (simple_protection .share [data .owner ], player_name ) then
68+ if table_contains (s_protect .share [data .owner ], player_name ) then
6969 return true
7070 end
7171 -- Globally shared area
@@ -82,28 +82,28 @@ simple_protection.can_access = function(pos, player_name)
8282 return false
8383end
8484
85- simple_protection .get_data = function (pos )
86- local str = simple_protection .get_location (vector .round (pos ))
87- return simple_protection .claims [str ]
85+ s_protect .get_data = function (pos )
86+ local str = s_protect .get_location (vector .round (pos ))
87+ return s_protect .claims [str ]
8888end
8989
90- simple_protection .get_y_axis = function (y )
91- y = (y + simple_protection .start_underground ) / simple_protection . claim_heigh
92- return math.floor (y ) * simple_protection . claim_heigh - simple_protection .start_underground
90+ s_protect .get_y_axis = function (y )
91+ y = (y + s_protect .start_underground ) / s_protect . claim_height
92+ return math.floor (y ) * s_protect . claim_height - s_protect .start_underground
9393end
9494
95- simple_protection .get_location = function (pos1 )
95+ s_protect .get_location = function (pos1 )
9696 local pos = {
97- x = pos1 .x / simple_protection .claim_size ,
98- y = (pos1 .y + simple_protection .start_underground ) / simple_protection . claim_heigh ,
99- z = pos1 .z / simple_protection .claim_size
97+ x = pos1 .x / s_protect .claim_size ,
98+ y = (pos1 .y + s_protect .start_underground ) / s_protect . claim_height ,
99+ z = pos1 .z / s_protect .claim_size
100100 }
101101 pos = vector .floor (pos )
102102 return pos .x .. " ," .. pos .y .. " ," .. pos .z
103103end
104104
105- simple_protection .get_center = function (pos1 )
106- local size = simple_protection .claim_size
105+ s_protect .get_center = function (pos1 )
106+ local size = s_protect .claim_size
107107 local pos = {
108108 x = pos1 .x / size ,
109109 y = pos1 .y + 1.5 ,
@@ -116,8 +116,8 @@ simple_protection.get_center = function(pos1)
116116 return pos
117117end
118118
119- simple_protection .load_claims = function ()
120- local file = io.open (simple_protection .file , " r" )
119+ s_protect .load_claims = function ()
120+ local file = io.open (s_protect .file , " r" )
121121 if not file then
122122 return
123123 end
@@ -133,15 +133,15 @@ simple_protection.load_claims = function()
133133 end
134134 end
135135 end
136- simple_protection .claims [data [1 ]] = {owner = data [2 ], shared = _shared }
136+ s_protect .claims [data [1 ]] = {owner = data [2 ], shared = _shared }
137137 end
138138 end
139139 io.close (file )
140140 minetest .log (" action" , " Loaded claim data" )
141141end
142142
143- simple_protection .load_shareall = function ()
144- local file = io.open (simple_protection .sharefile , " r" )
143+ s_protect .load_shareall = function ()
144+ local file = io.open (s_protect .sharefile , " r" )
145145 if not file then
146146 return
147147 end
@@ -156,17 +156,17 @@ simple_protection.load_shareall = function()
156156 table.insert (_shared , data [index ])
157157 end
158158 end
159- simple_protection .share [data [1 ]] = _shared
159+ s_protect .share [data [1 ]] = _shared
160160 end
161161 end
162162 end
163163 io.close (file )
164164 minetest .log (" action" , " Loaded shared claims" )
165165end
166166
167- simple_protection .save = function ()
168- local file = io.open (simple_protection .file , " w" )
169- for pos , data in pairs (simple_protection .claims ) do
167+ s_protect .save = function ()
168+ local file = io.open (s_protect .file , " w" )
169+ for pos , data in pairs (s_protect .claims ) do
170170 if data .owner and data .owner ~= " " then
171171 local shared = " "
172172 for i , player in ipairs (data .shared ) do
@@ -177,8 +177,8 @@ simple_protection.save = function()
177177 end
178178 io.close (file )
179179 -- Save globally shared areas
180- file = io.open (simple_protection .sharefile , " w" )
181- for name , players in pairs (simple_protection .share ) do
180+ file = io.open (s_protect .sharefile , " w" )
181+ for name , players in pairs (s_protect .share ) do
182182 if # players > 0 then
183183 local shared = " "
184184 for i , player in ipairs (players ) do
@@ -190,19 +190,29 @@ simple_protection.save = function()
190190 io.close (file )
191191end
192192
193- simple_protection .load_config = function ()
193+ s_protect .load_config = function ()
194194 -- Load defaults
195- dofile (simple_protection .mod_path .. " /settings.conf" )
196- local file = io.open (simple_protection .conf , " r" )
195+ dofile (s_protect .mod_path .. " /settings.conf" )
196+ local file = io.open (s_protect .conf , " r" )
197197 if file then
198198 io.close (file )
199199 -- Load existing config
200- dofile (simple_protection .conf )
200+ simple_protection = {}
201+ dofile (s_protect .conf )
202+
203+ -- Backwards compatibility
204+ for k , v in pairs (simple_protection ) do
205+ s_protect [k ] = v
206+ end
207+ simple_protection = nil
208+ if s_protect .claim_heigh then
209+ s_protect .claim_height = s_protect .claim_heigh
210+ end
201211 return
202212 end
203213 -- Duplicate configuration file on first time
204- local src = io.open (simple_protection .mod_path .. " /settings.conf" , " r" )
205- file = io.open (simple_protection .conf , " w" )
214+ local src = io.open (s_protect .mod_path .. " /settings.conf" , " r" )
215+ file = io.open (s_protect .conf , " w" )
206216
207217 while true do
208218 local block = src :read (128 ) -- 128B at once
0 commit comments