Arenas can now be renamed

master
Zughy 2020-06-21 00:26:55 +02:00
parent f1bf19e6d0
commit 2ab59fbb9c
2 changed files with 28 additions and 3 deletions

View File

@ -101,6 +101,11 @@ Arenas can be disabled too, via
`arena_lib.disable_arena(sender, mod, arena_name)` (or by entering the editor, as previously said).
In order to do that, no game must be taking place in that specific arena.
#### 1.2.4 Renaming an arena
An arena can be renamed via
`arena_lib.rename_arena(sender, mod, arena_name, new_name)`
In order to do so, it must be disabled first.
### 1.3 Arena phases
An arena comes in 4 phases, each one of them linked to a specific function:
* `waiting phase`: it's the queuing process. People hit a sign waiting for other players to play with

26
api.lua
View File

@ -293,6 +293,29 @@ end
function arena_lib.rename_arena(sender, mod, arena_name, new_name)
local id, arena = arena_lib.get_arena_by_name(mod, arena_name)
if not ARENA_LIB_EDIT_PRECHECKS_PASSED(sender, arena) then return end
-- se esiste già un'arena con il nuovo nome, annullo
if arena_lib.get_arena_by_name(mod, new_name) then
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] An arena with that name exists already!")))
return end
local old_name = arena.name
arena.name = new_name
minetest.chat_send_player(sender, "Arena " .. old_name .. " rinominata con successo in " .. new_name)
-- aggiorno storage e cartello
update_storage(false, mod, id, arena)
arena_lib.update_sign(arena.sign, arena)
end
-- Gli spawn points si impostano prendendo la coordinata del giocatore che lancia il comando.
-- Non ci possono essere più spawn points del numero massimo di giocatori.
-- 'param' può essere: "overwrite", "delete", "deleteall"
@ -354,7 +377,6 @@ function arena_lib.set_spawner(sender, mod, arena_name, teamID_or_name, param, I
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] No spawner with that ID to delete!")))
return end
--TODO: switch migliore dato che ci stanno dentro anche i team
arena.spawn_points[ID] = nil
-- se i waypoint sono mostrati, li aggiorno
@ -957,8 +979,6 @@ end
--------------------UTILS---------------------
----------------------------------------------
--TODO: rename_arena
-- mod è opzionale
function arena_lib.is_player_in_arena(p_name, mod)