mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-25 16:53:47 +01:00
rename chat to cc
also no need to expose cc directly to mtt
This commit is contained in:
parent
54c80e9242
commit
f01e90e8eb
29
init.lua
29
init.lua
@ -190,9 +190,9 @@ function factions.leave_faction(fname, player_name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Chat commands
|
-- Chat commands
|
||||||
local chat = {}
|
local cc = {}
|
||||||
|
|
||||||
function chat.create(name, params)
|
function cc.create(name, params)
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
if not faction_name then
|
if not faction_name then
|
||||||
@ -209,7 +209,7 @@ function chat.create(name, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.disband(name, params, not_admin)
|
function cc.disband(name, params, not_admin)
|
||||||
local password = params[2]
|
local password = params[2]
|
||||||
if not password then
|
if not password then
|
||||||
return false, S("Missing password.")
|
return false, S("Missing password.")
|
||||||
@ -240,7 +240,7 @@ function chat.disband(name, params, not_admin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.list()
|
function cc.list()
|
||||||
local faction_list = {}
|
local faction_list = {}
|
||||||
for k in pairs(facts) do
|
for k in pairs(facts) do
|
||||||
table.insert(faction_list, k)
|
table.insert(faction_list, k)
|
||||||
@ -253,7 +253,7 @@ function chat.list()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.info(name, params)
|
function cc.info(name, params)
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
if not faction_name then
|
if not faction_name then
|
||||||
local player_factions = factions.get_player_factions(name)
|
local player_factions = factions.get_player_factions(name)
|
||||||
@ -287,7 +287,7 @@ function chat.info(name, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.player_info(name, params)
|
function cc.player_info(name, params)
|
||||||
local player_name = params[2] or name
|
local player_name = params[2] or name
|
||||||
if not player_name then
|
if not player_name then
|
||||||
return false, S("Missing player name.")
|
return false, S("Missing player name.")
|
||||||
@ -327,7 +327,7 @@ function chat.player_info(name, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.join(name, params)
|
function cc.join(name, params)
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
if factions.mode_unique_faction and factions.get_player_factions(name) then
|
if factions.mode_unique_faction and factions.get_player_factions(name) then
|
||||||
@ -349,7 +349,7 @@ function chat.join(name, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.leave(name, params)
|
function cc.leave(name, params)
|
||||||
local player_factions = factions.get_player_factions(name)
|
local player_factions = factions.get_player_factions(name)
|
||||||
local number_factions = player_factions and table.getn(player_factions) or 0
|
local number_factions = player_factions and table.getn(player_factions) or 0
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
@ -380,7 +380,7 @@ function chat.leave(name, params)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.kick(name, params, not_admin)
|
function cc.kick(name, params, not_admin)
|
||||||
local target = params[2]
|
local target = params[2]
|
||||||
if not target then
|
if not target then
|
||||||
return false, S("Missing player name.")
|
return false, S("Missing player name.")
|
||||||
@ -416,7 +416,7 @@ function chat.kick(name, params, not_admin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.passwd(name, params, not_admin)
|
function cc.passwd(name, params, not_admin)
|
||||||
local password = params[2]
|
local password = params[2]
|
||||||
if not password then
|
if not password then
|
||||||
return false, S("Missing password.")
|
return false, S("Missing password.")
|
||||||
@ -446,7 +446,7 @@ function chat.passwd(name, params, not_admin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.chown(name, params, not_admin)
|
function cc.chown(name, params, not_admin)
|
||||||
local target = params[2]
|
local target = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
local faction_name = params[4]
|
local faction_name = params[4]
|
||||||
@ -483,7 +483,7 @@ function chat.chown(name, params, not_admin)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function chat.invite(_, params, not_admin)
|
function cc.invite(_, params, not_admin)
|
||||||
if not_admin then
|
if not_admin then
|
||||||
return false, S(
|
return false, S(
|
||||||
"Permission denied: You can't use this command, @1 priv is needed.",
|
"Permission denied: You can't use this command, @1 priv is needed.",
|
||||||
@ -523,12 +523,12 @@ local function handle_command(name, param)
|
|||||||
table.insert(params, p)
|
table.insert(params, p)
|
||||||
end
|
end
|
||||||
local action = params[1]
|
local action = params[1]
|
||||||
if not action or not chat[action:lower()] then
|
if not action or not cc[action:lower()] then
|
||||||
return false, S("Unknown subcommand. Run '/help factions' for help.")
|
return false, S("Unknown subcommand. Run '/help factions' for help.")
|
||||||
end
|
end
|
||||||
|
|
||||||
local not_admin = not minetest.get_player_privs(name)[factions.priv]
|
local not_admin = not minetest.get_player_privs(name)[factions.priv]
|
||||||
return chat[action:lower()](name, params, not_admin)
|
return cc[action:lower()](name, params, not_admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("factions", {
|
minetest.register_chatcommand("factions", {
|
||||||
@ -571,7 +571,6 @@ end
|
|||||||
|
|
||||||
-- Integration testing
|
-- Integration testing
|
||||||
if minetest.get_modpath("mtt") and mtt.enabled then
|
if minetest.get_modpath("mtt") and mtt.enabled then
|
||||||
factions.chat = chat
|
|
||||||
factions.handle_command = handle_command
|
factions.handle_command = handle_command
|
||||||
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/mtt.lua")
|
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/mtt.lua")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user