Bugfix: it was possible to enter the editor even when a match was taking place

master
Zughy 2020-12-02 02:36:28 +01:00
parent cd9cf85b33
commit 5836c1ca35
3 changed files with 9 additions and 5 deletions

View File

@ -163,13 +163,14 @@ ChatCmdBuilder.new("NAMEOFYOURCOMMAND", function(cmd)
#### 1.2.3 Enabling an arena
When a sign has been set, it won't work. This because an arena must be enabled manually via
`arena_lib.enable_arena(sender, mod, arena_name)` or by using the Enable and Leave button in the editor.
If all the conditions are met, you'll receive a confirmation. If not, you'll receive the reason why it didn't through and the arena will remain disabled. Conditions are:
If all the conditions are met, it'll return `true` and you'll receive a confirmation. If not, you'll receive the reason why it didn't through and the arena will remain disabled. Conditions are:
* all spawn points set
* sign placed
* potential custom checks through `arena_lib.on_enable` callback
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.
In order to do that, no game must be taking place in that specific arena. If successful, it'll return `true` and any potential player in queue will be removed. It acts like `enable_arena` (with `arena_lib.on_disable` as callback)
### 1.3 Arena phases
An arena comes in 4 phases, each one of them linked to a specific function:

View File

@ -71,9 +71,9 @@ function arena_lib.enter_editor(sender, mod, arena_name)
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] There must be no one inside the editor of the arena to perform this command! (now inside: @1)", arenas_in_edit_mode[arena_name])))
return end
-- se l'arena è abilitata, la disabilito
-- se l'arena è abilitata, provo a disabilitiarla
if arena.enabled then
arena_lib.disable_arena(sender, mod, arena_name)
if not arena_lib.disable_arena(sender, mod, arena_name) then return end
end
local player = minetest.get_player_by_name(sender)

View File

@ -890,8 +890,9 @@ function arena_lib.enable_arena(sender, mod, arena_name, in_editor)
arena.enabled = true
arena_lib.update_sign(arena)
update_storage(false, mod, arena_ID, arena)
minetest.chat_send_player(sender, mod_ref.prefix .. S("Arena @1 successfully enabled", arena_name))
minetest.chat_send_player(sender, mod_ref.prefix .. S("Arena @1 successfully enabled", arena_name))
return true
end
@ -943,7 +944,9 @@ function arena_lib.disable_arena(sender, mod, arena_name)
arena.enabled = false
arena_lib.update_sign(arena)
update_storage(false, mod, arena_ID, arena)
minetest.chat_send_player(sender, mod_ref.prefix .. S("Arena @1 successfully disabled", arena_name))
return true
end