/all and /t chat commands implemented
parent
27cab5ab3b
commit
d802862ac7
4
api.lua
4
api.lua
|
@ -115,6 +115,10 @@ function arena_lib.register_minigame(mod, def)
|
|||
end
|
||||
end
|
||||
|
||||
if def.chat_all_prefix then
|
||||
mod_ref.chat_all_prefix = def.chat_all_prefix
|
||||
end
|
||||
|
||||
if def.chat_all_color then
|
||||
mod_ref.chat_all_color = def.chat_all_color
|
||||
end
|
||||
|
|
68
chat.lua
68
chat.lua
|
@ -1,71 +1,3 @@
|
|||
local S = minetest.get_translator("arena_lib")
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("kick", {
|
||||
|
||||
description = S("Kick a player from an ongoing game"),
|
||||
privs = {
|
||||
arenalib_admin = true,
|
||||
},
|
||||
|
||||
func = function(sender, param)
|
||||
local p_name = string.match(param, "^([%a%d_-]+)$")
|
||||
|
||||
-- se non è specificato niente, annullo
|
||||
if not p_name then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Unknown parameter!")))
|
||||
return false end
|
||||
|
||||
-- se il giocatore non è online, annullo
|
||||
if not minetest.get_player_by_name(p_name) then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This player is not online!")))
|
||||
return false end
|
||||
|
||||
-- se il giocatore non è in partita, annullo
|
||||
if not arena_lib.is_player_in_arena(p_name) then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e" ,S("[!] The player must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
minetest.chat_send_player(sender, S("Player successfully kicked"))
|
||||
arena_lib.remove_player_from_arena(p_name, 2)
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("quit", {
|
||||
|
||||
description = S("Quit an ongoing game"),
|
||||
|
||||
func = function(name, param)
|
||||
if not arena_lib.is_player_in_arena(name) then
|
||||
minetest.chat_send_player(name, minetest.colorize("#e6482e" , S("[!] You must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
local arena = arena_lib.get_arena_by_player(name)
|
||||
|
||||
-- se è l'ultimo giocatore rimasto, annullo
|
||||
if arena.players_amount == 1 then
|
||||
minetest.chat_send_player(p_name, minetest.colorize("#e6482e" ,S("[!] You can't perform this action if you're the only one left!")))
|
||||
return end
|
||||
|
||||
local mod_ref = arena_lib.mods[arena_lib.get_mod_by_player(name)]
|
||||
|
||||
-- se uso /quit e on_prequit ritorna false, annullo
|
||||
if mod_ref.on_prequit then
|
||||
if mod_ref.on_prequit(arena, name) == false then
|
||||
return false end
|
||||
end
|
||||
|
||||
arena_lib.remove_player_from_arena(name, 3)
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_on_chat_message(function(p_name, message)
|
||||
|
||||
if arena_lib.is_player_in_arena(p_name) then
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
local S = minetest.get_translator("arena_lib")
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("kick", {
|
||||
|
||||
description = S("Kick a player from an ongoing game"),
|
||||
privs = {
|
||||
arenalib_admin = true,
|
||||
},
|
||||
|
||||
func = function(sender, param)
|
||||
local p_name = string.match(param, "^([%a%d_-]+)$")
|
||||
|
||||
-- se non è specificato niente, annullo
|
||||
if not p_name then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Unknown parameter!")))
|
||||
return false end
|
||||
|
||||
-- se il giocatore non è online, annullo
|
||||
if not minetest.get_player_by_name(p_name) then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This player is not online!")))
|
||||
return false end
|
||||
|
||||
-- se il giocatore non è in partita, annullo
|
||||
if not arena_lib.is_player_in_arena(p_name) then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e" ,S("[!] The player must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
minetest.chat_send_player(sender, S("Player successfully kicked"))
|
||||
arena_lib.remove_player_from_arena(p_name, 2)
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("quit", {
|
||||
|
||||
description = S("Quit an ongoing game"),
|
||||
|
||||
func = function(name, param)
|
||||
|
||||
if not arena_lib.is_player_in_arena(name) then
|
||||
minetest.chat_send_player(name, minetest.colorize("#e6482e" , S("[!] You must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
local arena = arena_lib.get_arena_by_player(name)
|
||||
|
||||
-- se è l'ultimo giocatore rimasto, annullo
|
||||
if arena.players_amount == 1 then
|
||||
minetest.chat_send_player(p_name, minetest.colorize("#e6482e" ,S("[!] You can't perform this action if you're the only one left!")))
|
||||
return end
|
||||
|
||||
local mod_ref = arena_lib.mods[arena_lib.get_mod_by_player(name)]
|
||||
|
||||
-- se uso /quit e on_prequit ritorna false, annullo
|
||||
if mod_ref.on_prequit then
|
||||
if mod_ref.on_prequit(arena, name) == false then
|
||||
return false end
|
||||
end
|
||||
|
||||
arena_lib.remove_player_from_arena(name, 3)
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("all", {
|
||||
|
||||
description = S("Write a message in the arena global chat while in a game"),
|
||||
|
||||
func = function(name, param)
|
||||
|
||||
if not arena_lib.is_player_in_arena(name) then
|
||||
minetest.chat_send_player(name, minetest.colorize("#e6482e" , S("[!] You must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
local msg = string.match(param, ".*")
|
||||
local mod_ref = arena_lib.mods[arena_lib.get_mod_by_player(name)]
|
||||
local arena = arena_lib.get_arena_by_player(name)
|
||||
|
||||
arena_lib.send_message_players_in_arena(arena, minetest.colorize(mod_ref.chat_all_color, mod_ref.chat_all_prefix .. minetest.format_chat_message(name, msg)))
|
||||
return true
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
|
||||
minetest.register_chatcommand("t", {
|
||||
|
||||
description = S("Write a message in the arena team chat while in a game (if teams are enabled)"),
|
||||
|
||||
func = function(name, param)
|
||||
|
||||
if not arena_lib.is_player_in_arena(name) then
|
||||
minetest.chat_send_player(name, minetest.colorize("#e6482e" , S("[!] You must be in a game to perform this action!")))
|
||||
return false end
|
||||
|
||||
local msg = string.match(param, ".*")
|
||||
local mod_ref = arena_lib.mods[arena_lib.get_mod_by_player(name)]
|
||||
local arena = arena_lib.get_arena_by_player(name)
|
||||
local teamID = arena.players[name].teamID
|
||||
|
||||
if not teamID then
|
||||
minetest.chat_send_player(name, minetest.colorize("#e6482e" , S("[!] Teams are not enabled!")))
|
||||
return false end
|
||||
|
||||
arena_lib.send_message_players_in_arena(arena, minetest.colorize(mod_ref.chat_team_color, mod_ref.chat_team_prefix .. minetest.format_chat_message(name, msg), teamID))
|
||||
return true
|
||||
end
|
||||
})
|
1
init.lua
1
init.lua
|
@ -3,6 +3,7 @@ local version = "3.3.0-dev"
|
|||
dofile(minetest.get_modpath("arena_lib") .. "/api.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/callbacks.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/chat.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/commands.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/debug_utilities.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/_hud/hud_main.lua")
|
||||
dofile(minetest.get_modpath("arena_lib") .. "/_hud/hud_waypoints.lua")
|
||||
|
|
|
@ -49,13 +49,16 @@ You win the game due to not enough players=Hai vinto la partita per troppi pochi
|
|||
[!] This action can't be performed with no spawners set!=[!] Quest'azione non può essere eseguita senza punti di spawn impostati!
|
||||
Wooosh!=Wooosh!
|
||||
|
||||
# chat.lua
|
||||
# commands.lua
|
||||
Kick a player from an ongoing game=Caccia un giocatore da una partita in corso
|
||||
[!] This player is not online!=[!] Questo giocatore non è online!
|
||||
[!] The player must be in a game to perform this action!=[!] Il giocatore deve essere in partita per eseguire questa azione!
|
||||
[!] You must be in a game to perform this action!=[!] Devi essere in partita per eseguire questa azione!
|
||||
Quit an ongoing game=Abbandona una partita in corso
|
||||
[!] You can't perform this action if you're the only one left!=[!] Non puoi eseguire quest'azione se sei l'unico giocatore rimasto!
|
||||
Write a message in the arena global chat while in a game=Scrive un messaggio nella chat globale dell'arena mentre si è in una partita
|
||||
Write a message in the arena team chat while in a game (if teams are enabled)=Scrive un messaggio nella chat di squadra dell'arena mentre si è in una partita (se le squadre sono abilitate)
|
||||
[!] Teams are not enabled!=[!] Le squadre non sono abilitate!
|
||||
|
||||
# debug_utilities.lua
|
||||
name: =nome:
|
||||
|
|
|
@ -49,13 +49,16 @@ You win the game due to not enough players=
|
|||
[!] This action can't be performed with no spawners set!=
|
||||
Wooosh!=
|
||||
|
||||
# chat.lua
|
||||
# commands.lua
|
||||
Kick a player from an ongoing game=
|
||||
[!] This player is not online!=
|
||||
[!] The player must be in a game to perform this action!=
|
||||
[!] You must be in a game to perform this action!=
|
||||
Quit an ongoing game=
|
||||
[!] You can't perform this action if you're the only one left!=
|
||||
Write a message in the arena global chat while in a game=
|
||||
Write a message in the arena team chat while in a game (if teams are enabled)=
|
||||
[!] Teams are not enabled!=
|
||||
|
||||
# debug_utilities.lua
|
||||
name: =
|
||||
|
|
Loading…
Reference in New Issue