'disabled_damage_types' paramater implemented. Per minigame

master
Marco 2020-06-10 01:14:46 +02:00
parent 6f6edb438f
commit 86a16e7c2b
7 changed files with 42 additions and 7 deletions

View File

@ -129,8 +129,9 @@ arena_lib.register_minigame("yourmod", {parameter1, parameter2 etc})
"yourmod" is how arena_lib will store your mod inside its storage, and it's also what it needs in order to understand you're referring to that specific mod (that's why almost every `arena_lib` function contains "mod" as a parameter). You'll need it when calling for commands or callbacks.
The second field, on the contrary, is a table of parameters: they define the very features of your minigame. They are:
* `prefix`: what's going to appear in most of the lines printed by your mod. Default is `[arena_lib] `
* `teams`: a table of strings containing teams. If not declared, your minigame won't have teams and the table will be equal to `{-1}`. You can add as many teams as you like, as the number of spawners (and players) will be multiplied by the number of teams (so `max_players = 4` * 3 teams = `max_players = 12`)
* `hub_spawn_point`: where players will be teleported when a match _in your mod_ ends. Default is `{ x = 0, y = 20, z = 0 }`
* `teams`: a table of strings containing teams. If not declared, your minigame won't have teams and the table will be equal to `{-1}`. You can add as many teams as you like, as the number of spawners (and players) will be multiplied by the number of teams (so `max_players = 4` * 3 teams = `max_players = 12`)
* `disabled_damage_types`: a table containing which damage types will be disabled once in a game. Damage types are strings, the same as in reason.type in the [minetest API](https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L4414)
* `join_while_in_progress`: whether the minigame allows to join an ongoing match. Default is false
* `keep_inventory`: whether to keep players inventories when joining an arena. Default is false
* `show_nametags`: whether to show the players nametags while in game. Default is false

11
api.lua
View File

@ -67,8 +67,9 @@ function arena_lib.register_minigame(mod, def)
--default parameters
mod_ref.prefix = "[Arena_lib] "
mod_ref.teams = {}
mod_ref.hub_spawn_point = { x = 0, y = 20, z = 0}
mod_ref.teams = {}
mod_ref.disabled_damage_types = {}
mod_ref.join_while_in_progress = false
mod_ref.keep_inventory = false
mod_ref.show_nametags = false
@ -89,12 +90,16 @@ function arena_lib.register_minigame(mod, def)
mod_ref.prefix = def.prefix
end
if def.hub_spawn_point then
mod_ref.hub_spawn_point = def.hub_spawn_point
end
if def.teams and type(def.teams) == "table" then
mod_ref.teams = def.teams
end
if def.hub_spawn_point then
mod_ref.hub_spawn_point = def.hub_spawn_point
if def.disabled_damage_types and type(def.disabled_damage_types) == "table" then
mod_ref.disabled_damage_types = def.disabled_damage_types
end
if def.join_while_in_progress == true then

View File

@ -45,6 +45,16 @@ function arena_lib.print_arena_info(sender, mod, arena_name)
teams = "---"
end
-- concateno eventuali danni disabilitati
local disabled_damage_types = ""
if next(mod_ref.disabled_damage_types) then
for _, dmg_type in pairs(mod_ref.disabled_damage_types) do
disabled_damage_types = disabled_damage_types .. " " .. dmg_type
end
else
disabled_damage_types = "---"
end
-- concateno nomi giocatori
local names = ""
for pl, stats in pairs(arena.players) do
@ -146,6 +156,7 @@ function arena_lib.print_arena_info(sender, mod, arena_name)
minetest.colorize("#eea160", S("Name: ")) .. minetest.colorize("#cfc6b8", arena_name ) .. "\n" ..
minetest.colorize("#eea160", "ID: ") .. minetest.colorize("#cfc6b8", arena_ID) .. "\n" ..
minetest.colorize("#eea160", S("Teams: ")) .. minetest.colorize("#cfc6b8", teams) .. "\n" ..
minetest.colorize("#eea160", S("Disabled damage types: ")) .. minetest.colorize("#cfc6b8", disabled_damage_types) .. "\n" ..
min_players_per_team ..
max_players_per_team ..
minetest.colorize("#eea160", S("Players required: ")) .. minetest.colorize("#cfc6b8", arena_min_players) .. "\n" ..

View File

@ -58,6 +58,7 @@ Timer: =Timer:
current: =corrente:
Name: =Nome:
Teams: =Squadre:
Disabled damage types: =Tipi di danno disabilitati:
Players required: =Giocatori minimi:
Players supported: =Giocatori massimi:
Players inside: =Giocatori dentro:

View File

@ -59,6 +59,7 @@ Timer: =
current: =
Name: =
Teams: =
Disabled damage types: =
Players required: =
Players supported: =
Players inside: =

View File

@ -2,12 +2,15 @@ arena_lib.initialize("call of Zughy")
arena_lib.settings("call of Zughy", {
prefix = "[CoZ] ",
hub_spawn_point = { x = 5, y = 10, z = 4 },
teams = {
"red",
"blue"
},
hub_spawn_point = { x = 5, y = 10, z = 4 },
queue_waiting_time = 10,
disabled_damage_types = {
"fall"
},
queue_waiting_time = 20,
show_minimap = true,
properties = {
planting_locations = {{x=30, y=20, z=40}, {x=5, y=20, z=80}}, --you can override these parameters via your mod, of course
@ -21,7 +24,7 @@ arena_lib.settings("call of Zughy", {
has_bomb = false
},
team_properties = {
round_won = 0
rounds_won = 0
}
})

View File

@ -46,10 +46,23 @@ end)
minetest.register_on_player_hpchange(function(player, hp_change, reason)
local mod = arena_lib.get_mod_by_player(player:get_player_name())
-- se non è in partita, annullo
if not mod then return hp_change end
-- se è immune, annullo
if player:get_inventory():contains_item("main", "arena_lib:immunity") and reason.type ~= "respawn" then
return 0
end
-- se un tipo di danno è disabilitato, annullo
for _, disabled_damage in pairs(arena_lib.mods[mod].disabled_damage_types) do
if reason.type == disabled_damage then
return 0
end
end
return hp_change
end, true)