forked from minetest-mods/irc
Use return values in player_part.lua
.
Also minor style fixes.
This commit is contained in:
parent
d5ad8ffca4
commit
b5786979ab
@ -4,20 +4,18 @@
|
||||
|
||||
function irc:player_part(name)
|
||||
if not self.joined_players[name] then
|
||||
minetest.chat_send_player(name, "IRC: You are not in the channel.")
|
||||
return
|
||||
return false, "You are not in the channel"
|
||||
end
|
||||
self.joined_players[name] = nil
|
||||
minetest.chat_send_player(name, "IRC: You are now out of the channel.")
|
||||
return true, "You left the channel"
|
||||
end
|
||||
|
||||
function irc:player_join(name)
|
||||
if self.joined_players[name] then
|
||||
minetest.chat_send_player(name, "IRC: You are already in the channel.")
|
||||
return
|
||||
return false, "You are already in the channel"
|
||||
end
|
||||
self.joined_players[name] = true
|
||||
minetest.chat_send_player(name, "IRC: You are now in the channel.")
|
||||
return true, "You joined the channel"
|
||||
end
|
||||
|
||||
|
||||
@ -25,7 +23,7 @@ minetest.register_chatcommand("join", {
|
||||
description = "Join the IRC channel",
|
||||
privs = {shout=true},
|
||||
func = function(name, param)
|
||||
irc:player_join(name)
|
||||
return irc:player_join(name)
|
||||
end
|
||||
})
|
||||
|
||||
@ -33,7 +31,7 @@ minetest.register_chatcommand("part", {
|
||||
description = "Part the IRC channel",
|
||||
privs = {shout=true},
|
||||
func = function(name, param)
|
||||
irc:player_part(name)
|
||||
return irc:player_part(name)
|
||||
end
|
||||
})
|
||||
|
||||
@ -41,11 +39,13 @@ minetest.register_chatcommand("who", {
|
||||
description = "Tell who is currently on the channel",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
local s = ""
|
||||
for name, _ in pairs(irc.joined_players) do
|
||||
s = s..", "..name
|
||||
local out, n = { }, 0
|
||||
for name in pairs(irc.joined_players) do
|
||||
n = n + 1
|
||||
out[n] = name
|
||||
end
|
||||
minetest.chat_send_player(name, "Players On Channel:"..s)
|
||||
table.sort(out)
|
||||
return true, "Players in channel: "..table.concat(out, ", ")
|
||||
end
|
||||
})
|
||||
|
||||
@ -62,7 +62,7 @@ minetest.register_on_leaveplayer(function(player)
|
||||
end)
|
||||
|
||||
function irc:sendLocal(message)
|
||||
for name, _ in pairs(self.joined_players) do
|
||||
for name, _ in pairs(self.joined_players) do
|
||||
minetest.chat_send_player(name, message)
|
||||
end
|
||||
irc:logChat(message)
|
||||
|
Loading…
Reference in New Issue
Block a user