Added a priv check to placing trash

master
Nathan Salapat 2021-04-06 11:41:43 -05:00
parent cc7bd23bbe
commit 130c824035
1 changed files with 18 additions and 0 deletions

View File

@ -89,6 +89,15 @@ minetest.register_node('tasks:trash_1', {
fixed = {{-.4, -.5, -.4, .4, -.45, .4}}
},
on_drop = lobby.no_drop,
after_place_node = function(pos, placer)
if not minetest.check_player_privs(placer, {creative = true}) then
minetest.chat_send_player(placer:get_player_name(), 'Don\'t be a litter bug!')
minetest.remove_node(pos)
return true
else
return false
end
end,
on_punch = function(pos, node, puncher, pointed_thing)
local player_inv = puncher:get_inventory()
if not player_inv:contains_item('main', {name='tasks:trash_1', count = 1}) then
@ -125,6 +134,15 @@ for i = 2,4 do
fixed = {{-.4, -.5, -.4, .4, -.45, .4}}
},
on_drop = lobby.no_drop,
after_place_node = function(pos, placer)
if not minetest.check_player_privs(placer, {creative = true}) then
minetest.chat_send_player(placer:get_player_name(), 'Don\'t be a litter bug!')
minetest.remove_node(pos)
return true
else
return false
end
end,
on_punch = function(pos, node, puncher, pointed_thing)
local player_inv = puncher:get_inventory()
if not player_inv:contains_item('main', {name='tasks:trash_'..i, count = 1}) then