Allow multi-word chatcommand channels.
• Allows multi-word chatcommand channels, separated by a '.'. · Example: '@/test.test2' will run '/test test2'.
This commit is contained in:
parent
2318fc3c15
commit
cac278c217
|
@ -14,7 +14,8 @@ 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 chatcommand. This will run the chatcommand after the `@`. Any
|
||||||
|
instances of `.` in this command will be replaced with ` `.
|
||||||
- `#`: 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
|
@ -118,7 +118,7 @@ chat_channels.send_message = function(msg, c)
|
||||||
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
|
elseif c:sub(1, 2) == '@/' then
|
||||||
minetest.run_server_chatcommand(c:sub(3), msg)
|
minetest.run_server_chatcommand(c:sub(3):gsub('%.', ' '), msg)
|
||||||
if c == '@/s' then
|
if c == '@/s' then
|
||||||
minetest.display_chat_message('-' .. main_channel .. '- <' ..
|
minetest.display_chat_message('-' .. main_channel .. '- <' ..
|
||||||
localplayer .. '> (s) ' .. msg)
|
localplayer .. '> (s) ' .. msg)
|
||||||
|
@ -137,7 +137,7 @@ chat_channels.send_message = function(msg, c)
|
||||||
'- ' .. msg)
|
'- ' .. msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if messages_sent > 0 then
|
if messages_sent > 0 then
|
||||||
if #buffer > 0 then buffer = buffer .. '\n' end
|
if #buffer > 0 then buffer = buffer .. '\n' end
|
||||||
buffer = buffer .. '-' .. c .. '- <' .. localplayer .. '> ' .. msg
|
buffer = buffer .. '-' .. c .. '- <' .. localplayer .. '> ' .. msg
|
||||||
|
@ -179,7 +179,7 @@ minetest.register_on_sending_chat_messages(function(msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
channel = msg
|
channel = msg
|
||||||
if channel == main_channel then
|
if channel == main_channel then
|
||||||
show_main_channel = true
|
show_main_channel = true
|
||||||
end
|
end
|
||||||
minetest.display_chat_message('You have changed chat channels to '
|
minetest.display_chat_message('You have changed chat channels to '
|
||||||
|
@ -266,7 +266,7 @@ minetest.register_on_receiving_chat_messages(function(msg)
|
||||||
local user = m:sub(9)
|
local user = m:sub(9)
|
||||||
local s, e = user:find(': ')
|
local s, e = user:find(': ')
|
||||||
local user = user:sub(1, s - 1)
|
local user = user:sub(1, s - 1)
|
||||||
|
|
||||||
if chat_channels.player_in_channel(user, chan) then
|
if chat_channels.player_in_channel(user, chan) then
|
||||||
minetest.display_chat_message('-#' .. chan .. '- <' .. user ..
|
minetest.display_chat_message('-#' .. chan .. '- <' .. user ..
|
||||||
'> ' .. text)
|
'> ' .. text)
|
||||||
|
@ -304,7 +304,7 @@ minetest.register_on_receiving_chat_messages(function(msg)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return chat_channels.display_without_colours(msg)
|
return chat_channels.display_without_colours(msg)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue