diff options
author | cheapie <cheapiephp@gmail.com> | 2016-05-23 13:13:24 -0500 |
---|---|---|
committer | Auke Kok <sofar+github@foo-projects.org> | 2016-05-23 11:13:24 -0700 |
commit | 4c743f9c4d1d263c5c36edb6a5dbaab7e2bdc6e4 (patch) | |
tree | 534b75cb17a13463aae75e724a4037a5ac8c3927 | |
parent | b6e8913901aeceac2dbf4d6acde5b7342c97ce16 (diff) |
Add protection support to channel fields (#33)
-rw-r--r-- | digilines_inventory/init.lua | 5 | ||||
-rw-r--r-- | digilines_lcd/init.lua | 5 | ||||
-rw-r--r-- | digilines_lightsensor/init.lua | 5 | ||||
-rw-r--r-- | digilines_rtc/init.lua | 5 |
4 files changed, 20 insertions, 0 deletions
diff --git a/digilines_inventory/init.lua b/digilines_inventory/init.lua index a8e7ecf..0269d4e 100644 --- a/digilines_inventory/init.lua +++ b/digilines_inventory/init.lua @@ -61,6 +61,11 @@ minetest.register_node("digilines_inventory:chest", { return minetest.get_meta(pos):get_inventory():is_empty("main") end, on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then + minetest.record_protection_violation(pos, name) + return + end if fields.channel ~= nil then minetest.get_meta(pos):set_string("channel",fields.channel) end diff --git a/digilines_lcd/init.lua b/digilines_lcd/init.lua index ade3fca..fafa477 100644 --- a/digilines_lcd/init.lua +++ b/digilines_lcd/init.lua @@ -107,6 +107,11 @@ minetest.register_node("digilines_lcd:lcd", { end, on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then + minetest.record_protection_violation(pos, name) + return + end if (fields.channel) then minetest.get_meta(pos):set_string("channel", fields.channel) end diff --git a/digilines_lightsensor/init.lua b/digilines_lightsensor/init.lua index 7dda1ce..914899b 100644 --- a/digilines_lightsensor/init.lua +++ b/digilines_lightsensor/init.lua @@ -50,6 +50,11 @@ minetest.register_node("digilines_lightsensor:lightsensor", { meta:set_string("formspec", "field[channel;Channel;${channel}]") end, on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then + minetest.record_protection_violation(pos, name) + return + end if (fields.channel) then minetest.get_meta(pos):set_string("channel", fields.channel) end diff --git a/digilines_rtc/init.lua b/digilines_rtc/init.lua index 6b7bfaf..5abafc1 100644 --- a/digilines_rtc/init.lua +++ b/digilines_rtc/init.lua @@ -46,6 +46,11 @@ minetest.register_node("digilines_rtc:rtc", { meta:set_string("formspec", "field[channel;Channel;${channel}]") end, on_receive_fields = function(pos, formname, fields, sender) + local name = sender:get_player_name() + if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then + minetest.record_protection_violation(pos, name) + return + end if (fields.channel) then minetest.get_meta(pos):set_string("channel", fields.channel) end |