Add '@/' prefix
This commit is contained in:
parent
ff6c99dd1f
commit
782bfdf26f
|
@ -14,6 +14,7 @@ Chat channels are created automatically when adding the first user and deleted
|
||||||
The following channel prefixes exist:
|
The following channel prefixes exist:
|
||||||
|
|
||||||
- `@`: A PM. This will PM the user after the `@`.
|
- `@`: A PM. This will PM the user after the `@`.
|
||||||
|
- `@/`: A chatcommand. This will run the chatcommand after the `@`.
|
||||||
- `#`: A channel. This is just a group PM prefixed with the channel name. If
|
- `#`: A channel. This is just a group PM prefixed with the channel name. If
|
||||||
a user in the channel uses chat_channels and has you in a channel with the
|
a user in the channel uses chat_channels and has you in a channel with the
|
||||||
same name, the message will display as a chat message in the channel.
|
same name, the message will display as a chat message in the channel.
|
||||||
|
|
10
init.lua
10
init.lua
|
@ -106,6 +106,11 @@ chat_channels.send_message = function(msg, c)
|
||||||
show_main_channel = true
|
show_main_channel = true
|
||||||
minetest.send_chat_message('[off] ' .. msg)
|
minetest.send_chat_message('[off] ' .. msg)
|
||||||
return true, 'Message sent!'
|
return true, 'Message sent!'
|
||||||
|
elseif c:sub(1, 2) == '@/' then
|
||||||
|
minetest.run_server_chatcommand(c:sub(3), msg)
|
||||||
|
if c == '@/s' then
|
||||||
|
minetest.display_chat_message('-' .. c .. '- ' .. msg)
|
||||||
|
end
|
||||||
elseif prefix == '#' and not channels[c:sub(2)] then
|
elseif prefix == '#' and not channels[c:sub(2)] then
|
||||||
if c == channel then channel = '@' end
|
if c == channel then channel = '@' end
|
||||||
return false, 'The channel ' .. c .. ' does not exist!'
|
return false, 'The channel ' .. c .. ' does not exist!'
|
||||||
|
@ -144,7 +149,7 @@ minetest.register_on_sending_chat_messages(function(msg)
|
||||||
if cmdprefix ~= '#' or channels[msg:sub(2)] or msg == main_channel
|
if cmdprefix ~= '#' or channels[msg:sub(2)] or msg == main_channel
|
||||||
then
|
then
|
||||||
local players = chat_channels.get_channel_users(msg)
|
local players = chat_channels.get_channel_users(msg)
|
||||||
if players and msg ~= '@' then
|
if players and msg ~= '@' and msg:sub(1, 2) ~= '@/' then
|
||||||
local empty = true
|
local empty = true
|
||||||
for p = 1, #players do
|
for p = 1, #players do
|
||||||
if connected_players[players[p]] then
|
if connected_players[players[p]] then
|
||||||
|
@ -392,7 +397,8 @@ minetest.register_chatcommand('toggle_' .. main_channel:sub(2), {
|
||||||
show_main_channel = true
|
show_main_channel = true
|
||||||
return true, "You will now start to receive messages from "
|
return true, "You will now start to receive messages from "
|
||||||
.. main_channel .. "."
|
.. main_channel .. "."
|
||||||
elseif channel == main_channel or channel == '@[off]' then
|
elseif channel == main_channel or channel == '@[off]' or
|
||||||
|
channel:sub(1, 2) == '@/' then
|
||||||
return false, "You are currently in " .. main_channel
|
return false, "You are currently in " .. main_channel
|
||||||
.. "! Please change channels first."
|
.. "! Please change channels first."
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue