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)
|
function irc:player_part(name)
|
||||||
if not self.joined_players[name] then
|
if not self.joined_players[name] then
|
||||||
minetest.chat_send_player(name, "IRC: You are not in the channel.")
|
return false, "You are not in the channel"
|
||||||
return
|
|
||||||
end
|
end
|
||||||
self.joined_players[name] = nil
|
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
|
end
|
||||||
|
|
||||||
function irc:player_join(name)
|
function irc:player_join(name)
|
||||||
if self.joined_players[name] then
|
if self.joined_players[name] then
|
||||||
minetest.chat_send_player(name, "IRC: You are already in the channel.")
|
return false, "You are already in the channel"
|
||||||
return
|
|
||||||
end
|
end
|
||||||
self.joined_players[name] = true
|
self.joined_players[name] = true
|
||||||
minetest.chat_send_player(name, "IRC: You are now in the channel.")
|
return true, "You joined the channel"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -25,7 +23,7 @@ minetest.register_chatcommand("join", {
|
|||||||
description = "Join the IRC channel",
|
description = "Join the IRC channel",
|
||||||
privs = {shout=true},
|
privs = {shout=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
irc:player_join(name)
|
return irc:player_join(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -33,7 +31,7 @@ minetest.register_chatcommand("part", {
|
|||||||
description = "Part the IRC channel",
|
description = "Part the IRC channel",
|
||||||
privs = {shout=true},
|
privs = {shout=true},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
irc:player_part(name)
|
return irc:player_part(name)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -41,11 +39,13 @@ minetest.register_chatcommand("who", {
|
|||||||
description = "Tell who is currently on the channel",
|
description = "Tell who is currently on the channel",
|
||||||
privs = {},
|
privs = {},
|
||||||
func = function(name, param)
|
func = function(name, param)
|
||||||
local s = ""
|
local out, n = { }, 0
|
||||||
for name, _ in pairs(irc.joined_players) do
|
for name in pairs(irc.joined_players) do
|
||||||
s = s..", "..name
|
n = n + 1
|
||||||
|
out[n] = name
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, "Players On Channel:"..s)
|
table.sort(out)
|
||||||
|
return true, "Players in channel: "..table.concat(out, ", ")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ minetest.register_on_leaveplayer(function(player)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
function irc:sendLocal(message)
|
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)
|
minetest.chat_send_player(name, message)
|
||||||
end
|
end
|
||||||
irc:logChat(message)
|
irc:logChat(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user