New arena parameter: author
parent
7c2c9c3344
commit
a2474307ef
|
@ -1,13 +1,13 @@
|
|||
local S = minetest.get_translator("arena_lib")
|
||||
local FS = minetest.formspec_escape
|
||||
|
||||
local function get_rename_formspec() end
|
||||
local function get_rename_author_formspec() end
|
||||
local function get_properties_formspec() end
|
||||
local function get_timer_formspec() end
|
||||
local function get_delete_formspec() end
|
||||
|
||||
local settings_tools = {
|
||||
"arena_lib:settings_rename",
|
||||
"arena_lib:settings_rename_author",
|
||||
"arena_lib:settings_properties",
|
||||
"", -- timer_off/_on
|
||||
"",
|
||||
|
@ -52,17 +52,16 @@ minetest.register_craftitem("arena_lib:timer", {
|
|||
|
||||
|
||||
|
||||
minetest.register_tool("arena_lib:settings_rename_author", {
|
||||
|
||||
minetest.register_tool("arena_lib:settings_rename", {
|
||||
|
||||
description = S("Rename arena"),
|
||||
inventory_image = "arenalib_tool_settings_rename.png",
|
||||
description = S("Arena name and author"),
|
||||
inventory_image = "arenalib_tool_settings_nameauthor.png",
|
||||
groups = {not_in_creative_inventory = 1, oddly_breakable_by_hand = "2"},
|
||||
on_place = function() end,
|
||||
on_drop = function() end,
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
minetest.show_formspec(user:get_player_name(), "arena_lib:settings_rename", get_rename_formspec())
|
||||
minetest.show_formspec(user:get_player_name(), "arena_lib:settings_rename_author", get_rename_author_formspec())
|
||||
end
|
||||
})
|
||||
|
||||
|
@ -131,15 +130,19 @@ end
|
|||
---------------FUNZIONI LOCALI----------------
|
||||
----------------------------------------------
|
||||
|
||||
function get_rename_formspec()
|
||||
function get_rename_author_formspec()
|
||||
|
||||
local formspec = {
|
||||
"size[5.2,0.4]",
|
||||
"formspec_version[4]",
|
||||
"size[7,2.2]",
|
||||
"no_prepend[]",
|
||||
"bgcolor[;neither]",
|
||||
"field[0.2,0.25;4,1;rename;;]",
|
||||
"button[3.8,-0.05;1.7,1;rename_confirm;" .. S("Rename arena") .. "]",
|
||||
"field_close_on_enter[rename;false]"
|
||||
"field[0,0.1;3.7,0.7;rename;;]",
|
||||
"button[3.8,0.1;2,0.7;rename_confirm;" .. S("Rename arena") .. "]",
|
||||
"field[0,1;3.7,0.7;author;;]",
|
||||
"button[3.8,1;2,0.7;author_confirm;" .. S("Change author") .. "]",
|
||||
"field_close_on_enter[rename;false]",
|
||||
"field_close_on_enter[author;false]"
|
||||
}
|
||||
|
||||
return table.concat(formspec, "")
|
||||
|
@ -233,8 +236,9 @@ end
|
|||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
|
||||
if formname ~= "arena_lib:settings_timer" and formname ~= "arena_lib:settings_rename"
|
||||
and formname ~= "arena_lib:settings_properties" and formname ~= "arena_lib:settings_delete" then return end
|
||||
if formname ~= "arena_lib:settings_timer" and formname ~= "arena_lib:settings_rename_author"
|
||||
and formname ~= "arena_lib:settings_properties" and formname ~= "arena_lib:settings_delete" then
|
||||
return end
|
||||
|
||||
local p_name = player:get_player_name()
|
||||
local mod = player:get_meta():get_string("arena_lib_editor.mod")
|
||||
|
@ -255,17 +259,32 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
minetest.close_formspec(p_name, formname)
|
||||
end
|
||||
|
||||
-- GUI per rinominare arena
|
||||
elseif formname == "arena_lib:settings_rename" then
|
||||
-- GUI per rinominare arena e cambiare autore
|
||||
elseif formname == "arena_lib:settings_rename_author" then
|
||||
|
||||
if not fields.rename_confirm and not fields.key_enter then return end
|
||||
if not arena_lib.rename_arena(p_name, mod, arena_name, fields.rename, true) then return end
|
||||
if fields.key_enter then
|
||||
if fields.key_enter_field == "rename" then
|
||||
if not arena_lib.rename_arena(p_name, mod, arena_name, fields.rename, true) then return end
|
||||
|
||||
local p_meta = player:get_meta()
|
||||
local p_meta = player:get_meta()
|
||||
|
||||
arena_lib.update_arena_in_edit_mode_name(p_meta:get_string("arena_lib_editor.arena"), fields.rename)
|
||||
p_meta:set_string("arena_lib_editor.arena", fields.rename)
|
||||
minetest.close_formspec(p_name, formname)
|
||||
arena_lib.update_arena_in_edit_mode_name(p_meta:get_string("arena_lib_editor.arena"), fields.rename)
|
||||
p_meta:set_string("arena_lib_editor.arena", fields.rename)
|
||||
elseif fields.key_enter_field == "author" then
|
||||
arena_lib.set_author(p_name, mod, arena_name, fields.author, true)
|
||||
end
|
||||
|
||||
elseif fields.rename_confirm then
|
||||
if not arena_lib.rename_arena(p_name, mod, arena_name, fields.rename, true) then return end
|
||||
|
||||
local p_meta = player:get_meta()
|
||||
|
||||
arena_lib.update_arena_in_edit_mode_name(p_meta:get_string("arena_lib_editor.arena"), fields.rename)
|
||||
p_meta:set_string("arena_lib_editor.arena", fields.rename)
|
||||
|
||||
elseif fields.author_confirm then
|
||||
arena_lib.set_author(p_name, mod, arena_name, fields.author, true)
|
||||
end
|
||||
|
||||
-- GUI per modificare proprietà
|
||||
elseif formname == "arena_lib:settings_properties" then
|
||||
|
|
30
api.lua
30
api.lua
|
@ -28,6 +28,7 @@ local players_temp_storage = {} -- KEY: player_name, VALUE: {(int) hotbar_slot
|
|||
|
||||
local arena_default = {
|
||||
name = "",
|
||||
author = "",
|
||||
sign = {},
|
||||
players = {}, -- KEY: player name, VALUE: {kills, deaths, teamID, <player_properties>}
|
||||
teams = {-1},
|
||||
|
@ -375,13 +376,27 @@ function arena_lib.rename_arena(sender, mod, arena_name, new_name, in_editor)
|
|||
|
||||
update_storage(false, mod, id, arena)
|
||||
|
||||
minetest.chat_send_player(sender, S("Arena @1 successfully renamed in @2", old_name, new_name))
|
||||
minetest.chat_send_player(sender, arena_lib.mods[mod].prefix .. S("Arena @1 successfully renamed in @2", old_name, new_name))
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
function arena_lib.set_author(sender, mod, arena_name, author, in_editor)
|
||||
|
||||
local id, arena = arena_lib.get_arena_by_name(mod, arena_name)
|
||||
|
||||
if not in_editor then
|
||||
if not ARENA_LIB_EDIT_PRECHECKS_PASSED(sender, arena) then return end
|
||||
end
|
||||
|
||||
arena.author = author
|
||||
minetest.chat_send_player(sender, arena_lib.mods[mod].prefix .. S("@1's author succesfully changed (@2)", arena.name, arena.author))
|
||||
end
|
||||
|
||||
|
||||
|
||||
function arena_lib.change_arena_property(sender, mod, arena_name, property, new_value, in_editor)
|
||||
|
||||
local id, arena = arena_lib.get_arena_by_name(mod, arena_name)
|
||||
|
@ -978,6 +993,12 @@ function arena_lib.load_arena(mod, arena_ID)
|
|||
count = count +1
|
||||
end
|
||||
|
||||
-- mostro autore
|
||||
if arena.author ~= "" then
|
||||
local author_display_time = mod_ref.load_time < 3 and mod_ref.load_time or 3
|
||||
arena_lib.HUD_send_msg_all("hotbar", arena, S("Author: " .. arena.author), author_display_time)
|
||||
end
|
||||
|
||||
-- eventuale codice aggiuntivo
|
||||
if mod_ref.on_load then
|
||||
mod_ref.on_load(arena)
|
||||
|
@ -1630,6 +1651,13 @@ function init_storage(mod, mod_ref)
|
|||
end
|
||||
--^------------------ LEGACY UPDATE, to remove in 5.0 -------------------^
|
||||
|
||||
--v------------------ LEGACY UPDATE, to remove in 6.0 -------------------v
|
||||
if not arena.author then
|
||||
arena.author = ""
|
||||
to_update = true
|
||||
end
|
||||
--^------------------ LEGACY UPDATE, to remove in 6.0 -------------------^
|
||||
|
||||
-- gestione team
|
||||
if arena.teams_enabled and not next(mod_ref.teams) then -- se avevo abilitato i team e ora li ho rimossi
|
||||
arena.players_amount_per_team = nil
|
||||
|
|
|
@ -22,9 +22,10 @@ end
|
|||
|
||||
function arena_lib.print_arena_info(sender, mod, arena_name)
|
||||
local arena_ID, arena = arena_lib.get_arena_by_name(mod, arena_name)
|
||||
if arena == nil then
|
||||
|
||||
if not arena then
|
||||
minetest.chat_send_player(sender, minetest.colorize("#e6482e", S("[!] This arena doesn't exist!")))
|
||||
return end
|
||||
return end
|
||||
|
||||
local mod_ref = arena_lib.mods[mod]
|
||||
local arena_min_players = arena.min_players * #arena.teams
|
||||
|
@ -156,6 +157,7 @@ function arena_lib.print_arena_info(sender, mod, arena_name)
|
|||
minetest.chat_send_player(sender,
|
||||
minetest.colorize("#cfc6b8", "====================================") .. "\n" ..
|
||||
minetest.colorize("#eea160", S("Name: ")) .. minetest.colorize("#cfc6b8", arena_name ) .. "\n" ..
|
||||
minetest.colorize("#eea160", S("Author: ")) .. minetest.colorize("#cfc6b8", arena.author ) .. "\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" ..
|
||||
|
|
2
init.lua
2
init.lua
|
@ -21,4 +21,6 @@ dofile(modpath .. "/_editor/tools_spawner.lua")
|
|||
dofile(modpath .. "/_hud/hud_main.lua")
|
||||
dofile(modpath .. "/_hud/hud_waypoints.lua")
|
||||
|
||||
dofile(modpath .. "/SETTINGS.lua")
|
||||
|
||||
minetest.log("action", "[ARENA_LIB] Mod initialised, running version " .. version)
|
||||
|
|
|
@ -97,6 +97,7 @@ celebrating=in celebrazione
|
|||
waiting=in attesa
|
||||
Initial time: =Tempo iniziale:
|
||||
current: =corrente:
|
||||
Author: =Autore:
|
||||
Name: =Nome:
|
||||
Teams: =Squadre:
|
||||
Disabled damage types: =Tipi di danno disabilitati:
|
||||
|
@ -169,9 +170,11 @@ Teams: on (click to toggle off)=Squadre: attive (premi per disattivare)
|
|||
Teams: off (click to toggle on)=Squadre: non attive (premi per attivare)
|
||||
|
||||
# _editor/tools_settings.lua
|
||||
Rename arena=Rinomina arena
|
||||
Arena name and author=Nome arena e autore
|
||||
Arena properties=Proprietà arena
|
||||
Delete arena=Cancella arena
|
||||
Rename arena=Rinomina arena
|
||||
Change author=Cambia autore
|
||||
Overwrite=Sovrascrivi
|
||||
Set timer=Imposta timer
|
||||
Cancel=Annulla
|
||||
|
|
|
@ -98,6 +98,7 @@ waiting=
|
|||
Initial time: =
|
||||
current: =
|
||||
Name: =
|
||||
Author: =
|
||||
Teams: =
|
||||
Disabled damage types: =
|
||||
Players required: =
|
||||
|
@ -169,9 +170,11 @@ Teams: on (click to toggle off)=
|
|||
Teams: off (click to toggle on)=
|
||||
|
||||
# _editor/tools_settings.lua
|
||||
Rename arena=
|
||||
Arena name and author=
|
||||
Arena properties=
|
||||
Delete arena=
|
||||
Rename arena=
|
||||
Change author=
|
||||
Overwrite=
|
||||
Set timer=
|
||||
Cancel=
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 213 B After Width: | Height: | Size: 172 B |
Binary file not shown.
After Width: | Height: | Size: 154 B |
Loading…
Reference in New Issue