Autojoin on channel switch
This commit is contained in:
parent
bd137904dd
commit
f289e50af2
@ -4,12 +4,10 @@ local channel_invitation_string = "|#${channel_name}| Channel invite from (${fro
|
||||
.. "which you can send messages to the channel via #${channel_name}: message"
|
||||
local channel_invited_string = "|#${channel_name}| Invite sent to ${to_player}"
|
||||
local channel_deleted_string = "|#${channel_name}| Channel deleted"
|
||||
local channel_joined_string = "|#${channel_name}| Joined channel"
|
||||
local channel_left_string = "|#${channel_name}| Left channel"
|
||||
local channel_already_deleted_string = "|#${channel_name}| Channel seems to have already "
|
||||
.. "been deleted, will unregister channel from your list of channels"
|
||||
|
||||
local join_channel_sound = "beerchat_chirp" -- Sound when you join a channel
|
||||
local leave_channel_sound = "beerchat_chirp" -- Sound when you leave a channel
|
||||
local channel_invite_sound = "beerchat_chirp" -- Sound when sending/ receiving an invite to a channel
|
||||
|
||||
@ -181,19 +179,7 @@ local join_channel = {
|
||||
end
|
||||
end
|
||||
|
||||
if not beerchat.execute_callbacks('before_join', name, channel_name) then
|
||||
return false
|
||||
end
|
||||
|
||||
beerchat.add_player_channel(name, channel_name)
|
||||
|
||||
if beerchat.enable_sounds then
|
||||
minetest.sound_play(join_channel_sound,
|
||||
{ to_player = name, gain = beerchat.sounds_default_gain })
|
||||
end
|
||||
minetest.chat_send_player(name, beerchat.format_message(channel_joined_string,
|
||||
{ channel_name = channel_name }))
|
||||
return true
|
||||
return beerchat.join_channel(name, channel_name)
|
||||
end
|
||||
}
|
||||
|
||||
|
13
common.lua
13
common.lua
@ -47,6 +47,19 @@ beerchat.fix_player_channel = function(name, notify)
|
||||
beerchat.set_player_channel(name, beerchat.main_channel_name)
|
||||
end
|
||||
|
||||
beerchat.join_channel = function(name, channel, set_default)
|
||||
if not beerchat.execute_callbacks('before_join', name, channel) then
|
||||
return false
|
||||
end
|
||||
(set_default and beerchat.set_player_channel or beerchat.add_player_channel)(name, channel)
|
||||
if beerchat.enable_sounds then
|
||||
minetest.sound_play("beerchat_chirp", { to_player = name, gain = beerchat.sounds_default_gain })
|
||||
end
|
||||
local msg = beerchat.format_message("|#${channel_name}| Joined channel", { channel_name = channel })
|
||||
minetest.chat_send_player(name, msg)
|
||||
return true
|
||||
end
|
||||
|
||||
beerchat.has_player_muted_player = function(name, other_name)
|
||||
local cb_result = beerchat.execute_callbacks('before_check_muted', name, other_name)
|
||||
if cb_result ~= nil then
|
||||
|
@ -3,9 +3,17 @@
|
||||
-- e.g. #my-channel: hello everyone in my channel!
|
||||
|
||||
local function switch_channel(name, channel)
|
||||
local skip_sound
|
||||
if not beerchat.is_player_subscribed_to_channel(name, channel) then
|
||||
minetest.chat_send_player(name, "You need to join this channel in order to be able to switch to it")
|
||||
else
|
||||
if beerchat.channels[channel].password and beerchat.channels[channel].password ~= "" then
|
||||
minetest.chat_send_player(name, "Channel is protected, you need to join this channel with /jc command")
|
||||
return
|
||||
elseif not beerchat.join_channel(name, channel) then
|
||||
return
|
||||
end
|
||||
-- Skip channel switch sound because beerchat.join_channel will also play sound
|
||||
skip_sound = true
|
||||
end
|
||||
if not beerchat.execute_callbacks('before_switch_chan', name,
|
||||
beerchat.currentPlayerChannel[name], channel) then
|
||||
return
|
||||
@ -21,7 +29,7 @@ local function switch_channel(name, channel)
|
||||
.. "To switch back to the main channel, type #" .. beerchat.main_channel_name
|
||||
)
|
||||
end
|
||||
if beerchat.enable_sounds then
|
||||
if not skip_sound and beerchat.enable_sounds then
|
||||
minetest.sound_play(
|
||||
beerchat.channel_management_sound,
|
||||
{
|
||||
@ -31,7 +39,6 @@ local function switch_channel(name, channel)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
beerchat.register_on_chat_message(function(name, message)
|
||||
local channel_name, msg = string.match(message, "^#(%S+) ?(.*)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user