Possibility for minigames to declare a global minimum amount of players (closes #206)
This commit is contained in:
parent
57e902103d
commit
b9aacb4027
@ -65,6 +65,7 @@ There are no winners=Non ci sono vincitorɜ
|
|||||||
[!] Parameters don't seem right!=[!] I parametri hanno qualcosa che non va!
|
[!] Parameters don't seem right!=[!] I parametri hanno qualcosa che non va!
|
||||||
[!] Property type doesn't match, aborting!=[!] Il tipo della proprietà non corrisponde, annullo!
|
[!] Property type doesn't match, aborting!=[!] Il tipo della proprietà non corrisponde, annullo!
|
||||||
Parameter @1 successfully overwritten=Parametro @1 sovrascritto con successo
|
Parameter @1 successfully overwritten=Parametro @1 sovrascritto con successo
|
||||||
|
[!] This minigame needs at least @1 players!=[!] Questo minigioco ha bisogno di almeno @1 giocatorɜ!
|
||||||
Arena @1 successfully created=Arena @1 creata con successo
|
Arena @1 successfully created=Arena @1 creata con successo
|
||||||
Arena @1 successfully removed=Arena @1 rimossa con successo
|
Arena @1 successfully removed=Arena @1 rimossa con successo
|
||||||
Arena @1 successfully renamed in @2=Arena @1 rinominata con successo in @2
|
Arena @1 successfully renamed in @2=Arena @1 rinominata con successo in @2
|
||||||
|
@ -65,6 +65,7 @@ There are no winners=
|
|||||||
[!] Parameters don't seem right!=
|
[!] Parameters don't seem right!=
|
||||||
[!] Property type doesn't match, aborting!=
|
[!] Property type doesn't match, aborting!=
|
||||||
Parameter @1 successfully overwritten=
|
Parameter @1 successfully overwritten=
|
||||||
|
[!] This minigame needs at least @1 players!=
|
||||||
Arena @1 successfully created=
|
Arena @1 successfully created=
|
||||||
Arena @1 successfully removed=
|
Arena @1 successfully removed=
|
||||||
Arena @1 successfully renamed in @2=
|
Arena @1 successfully renamed in @2=
|
||||||
|
@ -101,6 +101,7 @@ function arena_lib.register_minigame(mod, def)
|
|||||||
mod_ref.fov = nil
|
mod_ref.fov = nil
|
||||||
mod_ref.camera_offset = nil
|
mod_ref.camera_offset = nil
|
||||||
mod_ref.hotbar = nil
|
mod_ref.hotbar = nil
|
||||||
|
mod_ref.min_players = 1
|
||||||
mod_ref.join_while_in_progress = false
|
mod_ref.join_while_in_progress = false
|
||||||
mod_ref.spectate_mode = true
|
mod_ref.spectate_mode = true
|
||||||
mod_ref.disable_inventory = false
|
mod_ref.disable_inventory = false
|
||||||
@ -190,6 +191,10 @@ function arena_lib.register_minigame(mod, def)
|
|||||||
mod_ref.hotbar.selected_image = def.hotbar.selected_image
|
mod_ref.hotbar.selected_image = def.hotbar.selected_image
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if def.min_players then
|
||||||
|
mod_ref.min_players = def.min_players
|
||||||
|
end
|
||||||
|
|
||||||
if def.join_while_in_progress == true then
|
if def.join_while_in_progress == true then
|
||||||
mod_ref.join_while_in_progress = def.join_while_in_progress
|
mod_ref.join_while_in_progress = def.join_while_in_progress
|
||||||
end
|
end
|
||||||
@ -385,6 +390,10 @@ function arena_lib.create_arena(sender, mod, arena_name, min_players, max_player
|
|||||||
if min_players > max_players or min_players == 0 or max_players < 2 then
|
if min_players > max_players or min_players == 0 or max_players < 2 then
|
||||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Parameters don't seem right!")))
|
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Parameters don't seem right!")))
|
||||||
return end
|
return end
|
||||||
|
|
||||||
|
if min_players > mod_ref.min_players then
|
||||||
|
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This minigame needs at least @1 players!", mod_ref.min_players)))
|
||||||
|
return end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ID = next_available_ID(mod_ref)
|
local ID = next_available_ID(mod_ref)
|
||||||
@ -401,6 +410,10 @@ function arena_lib.create_arena(sender, mod, arena_name, min_players, max_player
|
|||||||
arena.max_players = max_players
|
arena.max_players = max_players
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if arena.min_players < mod_ref.min_players then
|
||||||
|
arena.min_players = mod_ref.min_players
|
||||||
|
end
|
||||||
|
|
||||||
-- eventuali squadre
|
-- eventuali squadre
|
||||||
if #mod_ref.teams > 1 then
|
if #mod_ref.teams > 1 then
|
||||||
arena.teams = {}
|
arena.teams = {}
|
||||||
@ -572,7 +585,6 @@ function arena_lib.change_arena_property(sender, mod, arena_name, property, new_
|
|||||||
return end
|
return end
|
||||||
|
|
||||||
setfenv(func, {})
|
setfenv(func, {})
|
||||||
|
|
||||||
local good, result = pcall(func)
|
local good, result = pcall(func)
|
||||||
|
|
||||||
-- se le operazioni della funzione causano errori
|
-- se le operazioni della funzione causano errori
|
||||||
@ -617,9 +629,18 @@ function arena_lib.change_players_amount(sender, mod, arena_name, min_players, m
|
|||||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Parameters don't seem right!")))
|
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] Parameters don't seem right!")))
|
||||||
arena.min_players = old_min_players
|
arena.min_players = old_min_players
|
||||||
arena.max_players = old_max_players
|
arena.max_players = old_max_players
|
||||||
return end
|
return end
|
||||||
|
|
||||||
-- se i giocatori massimi sono cambiati, svuoto i vecchi punti rinascita per evitare problemi
|
local mod_ref = arena_lib.mods[mod]
|
||||||
|
|
||||||
|
-- se ha meno giocatorɜ di quellɜ richiestɜ dal minigioco, annullo
|
||||||
|
if arena.min_players < mod_ref.min_players then
|
||||||
|
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This minigame needs at least @1 players!", mod_ref.min_players)))
|
||||||
|
arena.min_players = old_min_players
|
||||||
|
arena.max_players = old_max_players
|
||||||
|
return end
|
||||||
|
|
||||||
|
-- se lɜ giocatorɜ massimɜ sono cambiatɜ, svuoto i vecchi punti rinascita per evitare problemi
|
||||||
if max_players and old_max_players ~= max_players then
|
if max_players and old_max_players ~= max_players then
|
||||||
arena_lib.set_spawner(sender, mod, arena_name, nil, "deleteall", nil, in_editor)
|
arena_lib.set_spawner(sender, mod, arena_name, nil, "deleteall", nil, in_editor)
|
||||||
end
|
end
|
||||||
@ -1349,7 +1370,7 @@ function init_storage(mod, mod_ref)
|
|||||||
local arena_max_players = arena.max_players * #arena.teams
|
local arena_max_players = arena.max_players * #arena.teams
|
||||||
|
|
||||||
-- reimposto punti rinascita se ho cambiato il numero di squadre
|
-- reimposto punti rinascita se ho cambiato il numero di squadre
|
||||||
if arena_max_players ~= #arena.spawn_points then
|
if arena_max_players ~= #arena.spawn_points and arena.enabled then
|
||||||
to_update = true
|
to_update = true
|
||||||
arena.enabled = false
|
arena.enabled = false
|
||||||
arena.spawn_points = {}
|
arena.spawn_points = {}
|
||||||
@ -1357,6 +1378,19 @@ function init_storage(mod, mod_ref)
|
|||||||
" has been reset due to not coinciding with the maximum amount of players (" .. arena_max_players .. ")")
|
" has been reset due to not coinciding with the maximum amount of players (" .. arena_max_players .. ")")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- aggiorna lɜ giocatorɜ minimɜ in caso di conflitto
|
||||||
|
if arena.min_players < mod_ref.min_players then
|
||||||
|
arena.min_players = mod_ref.min_players
|
||||||
|
if arena.max_players < mod_ref.min_players then
|
||||||
|
arena.max_players = mod_ref.min_players
|
||||||
|
arena.spawn_points = {}
|
||||||
|
arena.enabled = false
|
||||||
|
minetest.log("action", "[ARENA_LIB] spawn points of arena " .. arena.name ..
|
||||||
|
" has been reset due to not coinciding with the maximum amount of players (" .. arena_max_players .. ")")
|
||||||
|
end
|
||||||
|
to_update = true
|
||||||
|
end
|
||||||
|
|
||||||
-- gestione tempo
|
-- gestione tempo
|
||||||
if mod_ref.time_mode == "none" and arena.initial_time then -- se avevo abilitato il tempo e ora l'ho rimosso, lo tolgo dalle arene
|
if mod_ref.time_mode == "none" and arena.initial_time then -- se avevo abilitato il tempo e ora l'ho rimosso, lo tolgo dalle arene
|
||||||
arena.initial_time = nil
|
arena.initial_time = nil
|
||||||
|
@ -26,7 +26,6 @@ minetest.register_node("arena_lib:players_min", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local players_amount = user:get_meta():get_int("arena_lib_editor.players_number")
|
local players_amount = user:get_meta():get_int("arena_lib_editor.players_number")
|
||||||
|
@ -35,7 +35,6 @@ minetest.register_tool("arena_lib:spawner_add", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
|
|
||||||
@ -54,7 +53,6 @@ minetest.register_tool("arena_lib:spawner_remove", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local spawner_ID = user:get_meta():get_int("arena_lib_editor.spawner_ID")
|
local spawner_ID = user:get_meta():get_int("arena_lib_editor.spawner_ID")
|
||||||
@ -82,7 +80,6 @@ minetest.register_tool("arena_lib:spawner_team_add", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
||||||
@ -103,7 +100,6 @@ minetest.register_tool("arena_lib:spawner_team_remove", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local spawner_ID = user:get_meta():get_int("arena_lib_editor.spawner_ID")
|
local spawner_ID = user:get_meta():get_int("arena_lib_editor.spawner_ID")
|
||||||
@ -130,7 +126,6 @@ minetest.register_tool("arena_lib:spawner_team_switch", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
||||||
@ -163,7 +158,6 @@ minetest.register_tool("arena_lib:spawner_deleteall", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local p_name = user:get_player_name()
|
local p_name = user:get_player_name()
|
||||||
@ -184,7 +178,6 @@ minetest.register_tool("arena_lib:spawner_team_deleteall", {
|
|||||||
on_drop = function() end,
|
on_drop = function() end,
|
||||||
|
|
||||||
on_use = function(itemstack, user, pointed_thing)
|
on_use = function(itemstack, user, pointed_thing)
|
||||||
|
|
||||||
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
local mod = user:get_meta():get_string("arena_lib_editor.mod")
|
||||||
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
local arena_name = user:get_meta():get_string("arena_lib_editor.arena")
|
||||||
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
local team_ID = user:get_meta():get_int("arena_lib_editor.team_ID")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user