From f66336394e327fa7bd53d1769295263a99a1be89 Mon Sep 17 00:00:00 2001 From: hdastwb Date: Tue, 6 Aug 2013 13:26:05 -0400 Subject: [PATCH] added reserved teleport channels --- teleport_tube.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/teleport_tube.lua b/teleport_tube.lua index 6936a82..33bfed4 100644 --- a/teleport_tube.lua +++ b/teleport_tube.lua @@ -94,6 +94,25 @@ register_tube("pipeworks:teleport_tube","Teleporter pneumatic tube segment",tele end, on_receive_fields = function(pos,formname,fields,sender) local meta = minetest.get_meta(pos) + + --check for private channels + if fields.channel ~= nil then + local name, mode = fields.channel:match("^([^:;]+)([:;])") + if name and mode and name ~= sender:get_player_name() then + + --channels starting with '[name]:' can only be used by the named player + if mode == ":" then + minetest.chat_send_player(sender:get_player_name(), "Sorry, channel '"..fields.channel.."' is reserved for exclusive use by "..name) + return + + --channels starting with '[name];' can be used by other players, but cannot be received from + elseif mode == ";" and (meta:get_int("can_receive") ~= 0) == (fields["bt"] == nil) then + minetest.chat_send_player(sender:get_player_name(), "Sorry, receiving from channel '"..fields.channel.."' is reserved for "..name) + return + end + end + end + if fields.channel==nil then fields.channel=meta:get_string("channel") end meta:set_string("channel",fields.channel) remove_tube_in_file(pos)