@@ -74,35 +74,11 @@ minetest.register_node("digtron:inventory", set_logger({
74
74
return inv :is_empty (" main" )
75
75
end ,
76
76
77
- allow_metadata_inventory_put = function (pos , _ , _ , stack , player )
78
- local name = player :get_player_name ()
79
- if minetest .is_protected (pos , name ) then
80
- minetest .record_protection_violation (pos , name )
81
- return 0
82
- end
83
-
84
- return stack :get_count ()
85
- end ,
86
-
87
- allow_metadata_inventory_move = function (pos , _ , _ , _ , _ , count , player )
88
- local name = player :get_player_name ()
89
- if minetest .is_protected (pos , name ) then
90
- minetest .record_protection_violation (pos , name )
91
- return 0
92
- end
93
-
94
- return count
95
- end ,
77
+ allow_metadata_inventory_put = digtron .protected_allow_metadata_inventory_put ,
96
78
97
- allow_metadata_inventory_take = function (pos , _ , _ , stack , player )
98
- local name = player :get_player_name ()
99
- if minetest .is_protected (pos , name ) then
100
- minetest .record_protection_violation (pos , name )
101
- return 0
102
- end
79
+ allow_metadata_inventory_move = digtron .protected_allow_metadata_inventory_move ,
103
80
104
- return stack :get_count ()
105
- end ,
81
+ allow_metadata_inventory_take = digtron .protected_allow_metadata_inventory_take ,
106
82
107
83
-- Pipeworks compatibility
108
84
---- ------------------------------------------------------------
@@ -181,42 +157,19 @@ minetest.register_node("digtron:fuelstore", set_logger({
181
157
182
158
-- Only allow fuel items to be placed in fuel
183
159
allow_metadata_inventory_put = function (pos , listname , _ , stack , player )
184
- local name = player :get_player_name ()
185
- if minetest .is_protected (pos , name ) then
186
- minetest .record_protection_violation (pos , name )
160
+ if digtron .check_protected_and_record (pos , player ) then
187
161
return 0
188
162
end
189
163
190
- if listname == " fuel" then
191
- if minetest .get_craft_result ({method = " fuel" , width = 1 , items = {stack }}).time ~= 0 then
192
-
193
- return stack :get_count ()
194
- else
195
- return 0
196
- end
164
+ if listname == " fuel" and minetest .get_craft_result ({method = " fuel" , width = 1 , items = {stack }}).time ~= 0 then
165
+ return stack :get_count ()
197
166
end
198
167
return 0
199
168
end ,
200
169
201
- allow_metadata_inventory_move = function (pos , _ , _ , _ , _ , count , player )
202
- local name = player :get_player_name ()
203
- if minetest .is_protected (pos , name ) then
204
- minetest .record_protection_violation (pos , name )
205
- return 0
206
- end
207
-
208
- return count
209
- end ,
210
-
211
- allow_metadata_inventory_take = function (pos , _ , _ , stack , player )
212
- local name = player :get_player_name ()
213
- if minetest .is_protected (pos , name ) then
214
- minetest .record_protection_violation (pos , name )
215
- return 0
216
- end
170
+ allow_metadata_inventory_move = digtron .protected_allow_metadata_inventory_move ,
217
171
218
- return stack :get_count ()
219
- end ,
172
+ allow_metadata_inventory_take = digtron .protected_allow_metadata_inventory_take ,
220
173
221
174
can_dig = function (pos )
222
175
local meta = minetest .get_meta (pos )
@@ -308,9 +261,7 @@ minetest.register_node("digtron:combined_storage", set_logger({
308
261
309
262
-- Only allow fuel items to be placed in fuel
310
263
allow_metadata_inventory_put = function (pos , listname , _ , stack , player )
311
- local name = player :get_player_name ()
312
- if minetest .is_protected (pos , name ) then
313
- minetest .record_protection_violation (pos , name )
264
+ if digtron .check_protected_and_record (pos , player ) then
314
265
return 0
315
266
end
316
267
@@ -325,9 +276,7 @@ minetest.register_node("digtron:combined_storage", set_logger({
325
276
end ,
326
277
327
278
allow_metadata_inventory_move = function (pos , from_list , from_index , to_list , _ , count , player )
328
- local name = player :get_player_name ()
329
- if minetest .is_protected (pos , name ) then
330
- minetest .record_protection_violation (pos , name )
279
+ if digtron .check_protected_and_record (pos , player ) then
331
280
return 0
332
281
end
333
282
@@ -344,15 +293,7 @@ minetest.register_node("digtron:combined_storage", set_logger({
344
293
return 0
345
294
end ,
346
295
347
- allow_metadata_inventory_take = function (pos , _ , _ , stack , player )
348
- local name = player :get_player_name ()
349
- if minetest .is_protected (pos , name ) then
350
- minetest .record_protection_violation (pos , name )
351
- return 0
352
- end
353
-
354
- return stack :get_count ()
355
- end ,
296
+ allow_metadata_inventory_take = digtron .protected_allow_metadata_inventory_take ,
356
297
357
298
can_dig = function (pos )
358
299
local meta = minetest .get_meta (pos )
0 commit comments