Editor: arenas can be now renamed via editor (new section: settings)

This commit is contained in:
Zughy 2020-08-31 01:29:32 +02:00
parent a88a521b98
commit b695c388e9
11 changed files with 156 additions and 4 deletions

View File

@ -78,6 +78,27 @@ minetest.register_tool("arena_lib:editor_signs", {
minetest.register_tool("arena_lib:editor_settings", {
description = S("Settings"),
inventory_image = "arenalib_editor_settings.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)
arena_lib.HUD_send_msg("hotbar", user:get_player_name(), S("Arena settings"))
minetest.after(0, function()
arena_lib.give_settings_tools(user)
end)
end
})
minetest.register_tool("arena_lib:editor_info", {
description = S("Info"),

View File

@ -5,7 +5,7 @@ local editor_tools = {
"arena_lib:editor_players",
"arena_lib:editor_spawners",
"arena_lib:editor_signs",
"",
"arena_lib:editor_settings",
"",
"arena_lib:editor_info",
"arena_lib:editor_enable",

View File

@ -0,0 +1,91 @@
local S = minetest.get_translator("arena_lib")
local function get_rename_formspec() end
local function get_properties_formspec() end
local settings_tools = {
"arena_lib:settings_rename",
--"arena_lib:settings_properties",
"",
"",
"",
"",
"",
"arena_lib:editor_return",
"arena_lib:editor_quit",
}
minetest.register_tool("arena_lib:settings_rename", {
description = S("Rename arena"),
inventory_image = "arenalib_tool_settings_rename.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)
local p_name = user:get_player_name()
minetest.show_formspec(p_name, "arena_lib:settings_rename", get_rename_formspec(p_name))
end
})
minetest.register_tool("arena_lib:settings_properties", {
description = S("Arena properties"),
inventory_image = "arenalib_tool_settings_editor.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)
local p_name = user:get_player_name()
minetest.show_formspec(p_name, "arena_lib:settings_properties", get_properties_formspec(p_name))
end
})
function arena_lib.give_settings_tools(user)
user:get_inventory():set_list("main", settings_tools)
end
----------------------------------------------
---------------FUNZIONI LOCALI----------------
----------------------------------------------
function get_properties_formspec(p_name)
local formspec = {
"size[6,4]"
}
return table.concat(formspec, "")
end
function get_rename_formspec(p_name)
local formspec = {
"size[5.2,0.4]",
"no_prepend[]",
"bgcolor[;neither]",
"field[0.2,0.25;4,1;rename;;]",
"button[3.8,-0.05;1.5,1;rename_confirm;Rename Arena]",
"field_close_on_enter[rename;false]"
}
return table.concat(formspec, "")
end

View File

@ -1,6 +1,7 @@
local S = minetest.get_translator("arena_lib")
local function change_spawner_ID() end
local S = minetest.get_translator("arena_lib")
local spawners_tools_team = {
"arena_lib:spawner_team_add",
"arena_lib:spawner_team_remove",

View File

@ -324,11 +324,13 @@ end
function arena_lib.rename_arena(sender, mod, arena_name, new_name)
function arena_lib.rename_arena(sender, mod, arena_name, new_name, in_editor)
local id, arena = arena_lib.get_arena_by_name(mod, arena_name)
if not ARENA_LIB_EDIT_PRECHECKS_PASSED(sender, arena) then return end
if not in_editor then
if not ARENA_LIB_EDIT_PRECHECKS_PASSED(sender, arena) then return end
end
-- se esiste già un'arena con il nuovo nome, annullo
if arena_lib.get_arena_by_name(mod, new_name) then
@ -347,6 +349,7 @@ function arena_lib.rename_arena(sender, mod, arena_name, new_name)
update_storage(false, mod, id, arena)
minetest.chat_send_player(sender, S("Arena @1 successfully renamed in @2", old_name, new_name))
return true
end

View File

@ -14,6 +14,7 @@ dofile(minetest.get_modpath("arena_lib") .. "/_dependencies/parties.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/editor_main.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/editor_icons.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/tools_players.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/tools_settings.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/tools_sign.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_editor/tools_spawner.lua")
dofile(minetest.get_modpath("arena_lib") .. "/_hud/hud_main.lua")

View File

@ -163,6 +163,10 @@ Change the current number=Cambia il numero attuale
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 properties=Proprietà arena
# _editor/tools_spawner.lua
Add spawner=Aggiungi spawner
Remove spawner=Rimuovi spawner

View File

@ -163,6 +163,10 @@ Change the current number=
Teams: on (click to toggle off)=
Teams: off (click to toggle on)=
# _editor/tools_settings.lua
Rename arena=
Arena properties=
# _editor/tools_spawner.lua
Add spawner=
Remove spawner=

View File

@ -115,3 +115,30 @@ minetest.register_on_respawnplayer(function(player)
return true
end)
minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "arena_lib:settings_rename" and formname ~= "arena_lib:settings_editor" then return end
local p_name = player:get_player_name()
local mod = player:get_meta():get_string("arena_lib_editor.mod")
local arena_name = player:get_meta():get_string("arena_lib_editor.arena")
-- GUI per rinominare arena
if formname == "arena_lib:settings_rename" then
if fields.rename_confirm or fields.key_enter then
if arena_lib.rename_arena(p_name, mod, arena_name, fields.rename, true) then
player:get_meta():set_string("arena_lib_editor.arena", fields.rename)
minetest.close_formspec(p_name, formname)
end
end
-- GUI per modificare proprietà
else
end
end)

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B