changes
This commit is contained in:
parent
c29bce03c6
commit
81e4a2dc24
@ -1,3 +1,6 @@
|
|||||||
|
# These settings are out of date,
|
||||||
|
# look for `ctf._set(` lines in mods/capturetheflag/ etc and prepend `ctf.`
|
||||||
|
|
||||||
# Whether teams own the nodes around their flag
|
# Whether teams own the nodes around their flag
|
||||||
#ctf.node_ownership = true
|
#ctf.node_ownership = true
|
||||||
#ctf.flag_protect_distance = 25
|
#ctf.flag_protect_distance = 25
|
||||||
@ -21,8 +24,8 @@
|
|||||||
# news
|
# news
|
||||||
# flags
|
# flags
|
||||||
# diplo
|
# diplo
|
||||||
# admin
|
# settings
|
||||||
#ctf.team_gui_initial = news
|
#ctf.gui.team.initial = news
|
||||||
|
|
||||||
# Enable tabs in Team GUI
|
# Enable tabs in Team GUI
|
||||||
#ctf.flag_teleport_gui = true
|
#ctf.flag_teleport_gui = true
|
||||||
|
@ -148,6 +148,7 @@ function ctf.area.get_spawn(team)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function ctf.area.asset_flags(team)
|
function ctf.area.asset_flags(team)
|
||||||
|
--[[
|
||||||
if not team or not ctf.team(team) then
|
if not team or not ctf.team(team) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -161,5 +162,5 @@ function ctf.area.asset_flags(team)
|
|||||||
ctf.log("utils", "Replacing flag...")
|
ctf.log("utils", "Replacing flag...")
|
||||||
-- TODO: ctf.area.asset_flags
|
-- TODO: ctf.area.asset_flags
|
||||||
end
|
end
|
||||||
end
|
end]]--
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
-- Registered
|
||||||
ctf.registered_on_load = {}
|
ctf.registered_on_load = {}
|
||||||
function ctf.register_on_load(func)
|
function ctf.register_on_load(func)
|
||||||
table.insert(ctf.registered_on_load, func)
|
table.insert(ctf.registered_on_load, func)
|
||||||
@ -11,10 +12,12 @@ function ctf.register_on_init(func)
|
|||||||
table.insert(ctf.registered_on_init, func)
|
table.insert(ctf.registered_on_init, func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Debug helpers
|
||||||
function ctf.error(area, msg)
|
function ctf.error(area, msg)
|
||||||
minetest.log("error", "CTF::" .. area .. " - " ..msg)
|
minetest.log("error", "CTF::" .. area .. " - " ..msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ctf.log(area, msg)
|
function ctf.log(area, msg)
|
||||||
if area and area ~= "" then
|
if area and area ~= "" then
|
||||||
print("[CaptureTheFlag] (" .. area .. ") " .. msg)
|
print("[CaptureTheFlag] (" .. area .. ") " .. msg)
|
||||||
@ -22,11 +25,19 @@ function ctf.log(area, msg)
|
|||||||
print("[CaptureTheFlag] " .. msg)
|
print("[CaptureTheFlag] " .. msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function ctf.action(area, msg)
|
||||||
|
if area and area ~= "" then
|
||||||
|
minetest.log("action", "[CaptureTheFlag] (" .. area .. ") " .. msg)
|
||||||
|
else
|
||||||
|
nubetest.log("action", "[CaptureTheFlag] " .. msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
function ctf.warning(area, msg)
|
function ctf.warning(area, msg)
|
||||||
print("WARNING: [CaptureTheFlag] (" .. area .. ") " .. msg)
|
print("WARNING: [CaptureTheFlag] (" .. area .. ") " .. msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function ctf.init()
|
function ctf.init()
|
||||||
ctf.log("init", "Initialising!")
|
ctf.log("init", "Initialising!")
|
||||||
|
|
||||||
@ -48,12 +59,7 @@ function ctf.init()
|
|||||||
ctf._set("flag_names", true)
|
ctf._set("flag_names", true)
|
||||||
|
|
||||||
-- Settings: User Interface
|
-- Settings: User Interface
|
||||||
ctf._set("gui", true)
|
|
||||||
ctf._set("hud", true)
|
ctf._set("hud", true)
|
||||||
ctf._set("team_gui", true)
|
|
||||||
ctf._set("flag_teleport_gui", true)
|
|
||||||
ctf._set("spawn_in_flag_teleport_gui", false)
|
|
||||||
ctf._set("news_gui", true)
|
|
||||||
|
|
||||||
-- Settings: Teams
|
-- Settings: Teams
|
||||||
ctf._set("diplomacy", true)
|
ctf._set("diplomacy", true)
|
||||||
@ -92,6 +98,11 @@ function ctf.setting(name)
|
|||||||
local set = minetest.setting_get("ctf."..name) or
|
local set = minetest.setting_get("ctf."..name) or
|
||||||
minetest.setting_get("ctf_"..name)
|
minetest.setting_get("ctf_"..name)
|
||||||
local dset = ctf._defsettings[name]
|
local dset = ctf._defsettings[name]
|
||||||
|
if dset == nil then
|
||||||
|
ctf.error("setting", "No such setting - " .. name)
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
if set ~= nil then
|
if set ~= nil then
|
||||||
if type(dset) == "number" then
|
if type(dset) == "number" then
|
||||||
return tonumber(set)
|
return tonumber(set)
|
||||||
@ -100,11 +111,8 @@ function ctf.setting(name)
|
|||||||
else
|
else
|
||||||
return set
|
return set
|
||||||
end
|
end
|
||||||
elseif dset ~= nil then
|
|
||||||
return ctf._defsettings[name]
|
|
||||||
else
|
else
|
||||||
ctf.log("setting", name.." not found!")
|
return dset
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -191,8 +199,22 @@ function ctf.count_players_in_team(team)
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ctf.new_player(name)
|
||||||
|
ctf.log("team", "Creating player " .. name)
|
||||||
|
ctf.players[name] = {
|
||||||
|
name = name
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
-- get a player
|
-- get a player
|
||||||
function ctf.player(name)
|
function ctf.player(name)
|
||||||
|
if not ctf.players[name] then
|
||||||
|
ctf.new_player(name)
|
||||||
|
end
|
||||||
|
return ctf.players[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ctf.player_or_nil(name)
|
||||||
return ctf.players[name]
|
return ctf.players[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -207,13 +229,9 @@ function ctf.join(name, team, force)
|
|||||||
|
|
||||||
local player = ctf.player(name)
|
local player = ctf.player(name)
|
||||||
|
|
||||||
if not player then
|
if not force and not ctf.setting("players_can_change_team")
|
||||||
player = {name = name}
|
and not player.team then
|
||||||
ctf.players[name] = player
|
ctf.action("teams", name .. " attempted to change to " .. team)
|
||||||
end
|
|
||||||
|
|
||||||
if not force and not ctf.setting("players_can_change_team") and (not player.team or player.team == "") then
|
|
||||||
minetest.log("action", name .. " attempted to change to " .. team)
|
|
||||||
minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!")
|
minetest.chat_send_player(name, "You are not allowed to switch teams, traitor!")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -237,12 +255,13 @@ function ctf.join(name, team, force)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- TODO: refactor ctf.add_user etc
|
||||||
-- Add a player to a team in data structures
|
-- Add a player to a team in data structures
|
||||||
function ctf.add_user(team, user)
|
function ctf.add_user(team, user)
|
||||||
local _team = ctf.team(team)
|
local _team = ctf.team(team)
|
||||||
local _user = ctf.player(user.name)
|
local _user = ctf.player(user.name)
|
||||||
if _team and user and user.name then
|
if _team and user and user.name then
|
||||||
if _user and _user.team and ctf.team(_user.team) then
|
if _user.team and ctf.team(_user.team) then
|
||||||
ctf.teams[_user.team].players[user.name] = nil
|
ctf.teams[_user.team].players[user.name] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ ctf.flag_func = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf.players and ctf.team(team) and ctf.player(player) and ctf.player(player).team then
|
if ctf.team(team) and ctf.player(player).team then
|
||||||
if ctf.player(player).team ~= team then
|
if ctf.player(player).team ~= team then
|
||||||
local diplo = ctf.diplo.get(team,ctf.player(player).team)
|
local diplo = ctf.diplo.get(team, ctf.player(player).team)
|
||||||
|
|
||||||
if not diplo then
|
if not diplo then
|
||||||
diplo = ctf.setting("default_diplo_state")
|
diplo = ctf.setting("default_diplo_state")
|
||||||
@ -83,11 +83,6 @@ ctf.flag_func = {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--ctf.post(team,{msg=flag_name.." has been captured by "..ctf.player(player).team,icon="flag_red"})
|
|
||||||
--ctf.post(ctf.player(player).team,{msg=player.." captured '"..flag_name.."' from "..team,icon="flag_green"})
|
|
||||||
--ctf.post(team,{msg="The flag at ("..pos.x..","..pos.z..") has been captured by "..ctf.player(player).team,icon="flag_red"})
|
|
||||||
--ctf.post(ctf.player(player).team,{msg=player.." captured flag ("..pos.x..","..pos.z..") from "..team,icon="flag_green"})
|
|
||||||
|
|
||||||
local flag_name = flag.name
|
local flag_name = flag.name
|
||||||
if ctf.setting("flag_capture_take") then
|
if ctf.setting("flag_capture_take") then
|
||||||
if flag_name and flag_name~="" then
|
if flag_name and flag_name~="" then
|
||||||
|
@ -1,33 +1,74 @@
|
|||||||
ctf.gui = {}
|
ctf.gui = {
|
||||||
|
tabs = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctf.register_on_init(function()
|
||||||
|
ctf._set("gui", true)
|
||||||
|
ctf._set("gui.team", true)
|
||||||
|
ctf._set("gui.team.initial", "news")
|
||||||
|
ctf._set("gui.team.teleport_to_flag", true)
|
||||||
|
ctf._set("gui.team.teleport_to_spawn", false)
|
||||||
|
|
||||||
|
for name, tab in pairs(ctf.gui.tabs) do
|
||||||
|
ctf._set("gui.tab." .. name, true)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
function ctf.gui.register_tab(name, title, func)
|
||||||
|
ctf.gui.tabs[name] = {
|
||||||
|
name = name,
|
||||||
|
title = title,
|
||||||
|
func = func
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ctf.gui.show(name, tab, team)
|
||||||
|
if not tab then
|
||||||
|
tab = ctf.setting("gui.team.initial") or "news"
|
||||||
|
end
|
||||||
|
|
||||||
|
if not tab or not ctf.gui.tabs[tab] or not name or name == "" then
|
||||||
|
ctf.log("gui", "Invalid tab or name given to ctf.gui.show")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not ctf.setting("gui.team") or not ctf.setting("gui") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not team or not ctf.team(team) then
|
||||||
|
team = ctf.player(name).team
|
||||||
|
print(team)
|
||||||
|
end
|
||||||
|
|
||||||
|
if team and team ~= "" and ctf.team(team) then
|
||||||
|
ctf.action("gui", name .. " views " .. team .. "'s " .. tab .. " page")
|
||||||
|
ctf.gui.tabs[tab].func(name, team)
|
||||||
|
else
|
||||||
|
ctf.log("gui", "Invalid team given to ctf.gui.show")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Get tab buttons
|
-- Get tab buttons
|
||||||
function ctf.gui.tabs(name,team)
|
function ctf.gui.get_tabs(name, team)
|
||||||
local result = ""
|
local result = ""
|
||||||
local id = 1
|
local id = 1
|
||||||
local function addtab(name,text)
|
local function addtab(name,text)
|
||||||
result = result .. "button["..(id*2-1)..",0;2,1;"..name..";"..text.."]"
|
result = result .. "button["..(id*2-1)..",0;2,1;"..name..";"..text.."]"
|
||||||
id = id + 1
|
id = id + 1
|
||||||
end
|
end
|
||||||
if ctf.setting("news_gui") then
|
|
||||||
addtab("board","News")
|
for name, tab in pairs(ctf.gui.tabs) do
|
||||||
|
if ctf.setting("gui.tab."..name) then
|
||||||
|
addtab(name, tab.title)
|
||||||
end
|
end
|
||||||
if ctf.setting("flag_teleport_gui") then
|
|
||||||
addtab("flags","Flags")
|
|
||||||
end
|
end
|
||||||
if ctf.setting("diplomacy") then
|
|
||||||
addtab("diplo","Diplomacy")
|
|
||||||
end
|
|
||||||
addtab("admin","Settings")
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Team interface
|
-- Team interface
|
||||||
function ctf.gui.team_board(name,team)
|
ctf.gui.register_tab("news", "News", function(name, team)
|
||||||
ctf.log("gui", name .. " views team_board")
|
|
||||||
if not ctf.setting("team_gui") or not ctf.setting("gui") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
local result = ""
|
||||||
local data = ctf.teams[team].log
|
local data = ctf.teams[team].log
|
||||||
|
|
||||||
@ -37,9 +78,9 @@ function ctf.gui.team_board(name,team)
|
|||||||
|
|
||||||
local amount = 0
|
local amount = 0
|
||||||
|
|
||||||
for i=1,#data do
|
for i = 1, #data do
|
||||||
if data[i].type == "request" then
|
if data[i].type == "request" then
|
||||||
if ctf.can_mod(name,team)==true then
|
if ctf.can_mod(name, team) then
|
||||||
amount = amount + 2
|
amount = amount + 2
|
||||||
local height = (amount*0.5) + 0.5
|
local height = (amount*0.5) + 0.5
|
||||||
amount = amount + 1
|
amount = amount + 1
|
||||||
@ -59,18 +100,17 @@ function ctf.gui.team_board(name,team)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
amount = amount + 1
|
amount = amount + 1
|
||||||
local height = (amount*0.5)+0.5
|
local height = (amount*0.5) + 0.5
|
||||||
|
|
||||||
if height > 5 then
|
if height > 5 then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
result = result .. "label[0.5,".. height ..";".. minetest.formspec_escape(data[i].msg) .."]"
|
result = result .. "label[0.5,".. height ..";".. minetest.formspec_escape(data[i].msg) .."]"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ctf.can_mod(name,team)==true then
|
if ctf.can_mod(name, team) then
|
||||||
result = result .. "button[4,6;2,1;clear;Clear all]"
|
result = result .. "button[4,6;2,1;clear;Clear all]"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -79,20 +119,14 @@ function ctf.gui.team_board(name,team)
|
|||||||
"label[0.5,1.5;News such as attacks will appear here]"
|
"label[0.5,1.5;News such as attacks will appear here]"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(name, "ctf:board",
|
minetest.show_formspec(name, "ctf:news",
|
||||||
"size[10,7]"..
|
"size[10,7]"..
|
||||||
ctf.gui.tabs(name,team)..
|
ctf.gui.get_tabs(name,team)..
|
||||||
result
|
result)
|
||||||
)
|
end)
|
||||||
end
|
|
||||||
|
|
||||||
-- Team interface
|
-- Team interface
|
||||||
function ctf.gui.team_flags(name,team)
|
ctf.gui.register_tab("flags", "Flags", function(name, team)
|
||||||
ctf.log("gui", name .. " views team_flags")
|
|
||||||
if not ctf.setting("team_gui") or not ctf.setting("gui") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
local result = ""
|
||||||
local t = ctf.team(team)
|
local t = ctf.team(team)
|
||||||
|
|
||||||
@ -104,8 +138,8 @@ function ctf.gui.team_flags(name,team)
|
|||||||
local y = 2
|
local y = 2
|
||||||
result = result .. "label[1,1;Click a flag button to go there]"
|
result = result .. "label[1,1;Click a flag button to go there]"
|
||||||
|
|
||||||
if ctf.setting("spawn_in_flag_teleport_gui") and minetest.get_setting("static_spawnpoint") then
|
if ctf.setting("gui.team.teleport_to_spawn") and minetest.get_setting("static_spawnpoint") then
|
||||||
local x,y,z = string.match(minetest.get_setting("static_spawnpoint"),"(%d+),(%d+),(%d+)")
|
local x,y,z = string.match(minetest.get_setting("static_spawnpoint"), "(%d+),(%d+),(%d+)")
|
||||||
|
|
||||||
result = result ..
|
result = result ..
|
||||||
"button[" .. x .. "," .. y .. ";2,1;goto_"
|
"button[" .. x .. "," .. y .. ";2,1;goto_"
|
||||||
@ -115,7 +149,7 @@ function ctf.gui.team_flags(name,team)
|
|||||||
x = x + 2
|
x = x + 2
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#t.flags do
|
for i=1, #t.flags do
|
||||||
local f = t.flags[i]
|
local f = t.flags[i]
|
||||||
|
|
||||||
if x > 8 then
|
if x > 8 then
|
||||||
@ -142,18 +176,12 @@ function ctf.gui.team_flags(name,team)
|
|||||||
|
|
||||||
minetest.show_formspec(name, "ctf:flags",
|
minetest.show_formspec(name, "ctf:flags",
|
||||||
"size[10,7]"..
|
"size[10,7]"..
|
||||||
ctf.gui.tabs(name,team)..
|
ctf.gui.get_tabs(name,team)..
|
||||||
result
|
result)
|
||||||
)
|
end)
|
||||||
end
|
|
||||||
|
|
||||||
-- Team interface
|
-- Team interface
|
||||||
function ctf.gui.team_dip(name,team)
|
ctf.gui.register_tab("diplo", "Diplomacy", function(name, team)
|
||||||
ctf.log("gui", name .. " views team_dip")
|
|
||||||
if not ctf.setting("team_gui") or not ctf.setting("gui") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local result = ""
|
local result = ""
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
@ -203,24 +231,15 @@ function ctf.gui.team_dip(name,team)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(name, "ctf:dip",
|
minetest.show_formspec(name, "ctf:diplo",
|
||||||
"size[10,7]"..
|
"size[10,7]"..
|
||||||
ctf.gui.tabs(name,team)..
|
ctf.gui.get_tabs(name,team)..
|
||||||
result
|
result
|
||||||
)
|
)
|
||||||
end
|
end)
|
||||||
|
|
||||||
-- Team interface
|
-- Team interface
|
||||||
function ctf.gui.team_settings(name,team)
|
ctf.gui.register_tab("settings", "Settings", function(name, team)
|
||||||
ctf.log("gui", name .. " views team_settings")
|
|
||||||
if not ctf.setting("team_gui") or not ctf.setting("gui") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if not team or not ctf.team(team) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local color = ""
|
local color = ""
|
||||||
|
|
||||||
if ctf.team(team).data and ctf.team(team).data.color then
|
if ctf.team(team).data and ctf.team(team).data.color then
|
||||||
@ -235,50 +254,52 @@ function ctf.gui.team_settings(name,team)
|
|||||||
result = "label[0.5,1;You do not own this team!"
|
result = "label[0.5,1;You do not own this team!"
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.show_formspec(name, "ctf:team_settings",
|
minetest.show_formspec(name, "ctf:settings",
|
||||||
"size[10,7]"..
|
"size[10,7]"..
|
||||||
ctf.gui.tabs(name,team)..
|
ctf.gui.get_tabs(name,team)..
|
||||||
result
|
result
|
||||||
)
|
)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local function formspec_is_ctf_tab(fsname)
|
||||||
|
for name, tab in pairs(ctf.gui.tabs) do
|
||||||
|
if fsname == "ctf:" .. name then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
print(fsname .. " is not a ctf_tab")
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if formname=="ctf:board" or formname=="ctf:flags" or formname=="ctf:dip" or formname=="ctf:team_settings" then
|
if not formspec_is_ctf_tab(formname) then
|
||||||
if fields.flags then
|
return false
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
|
||||||
ctf.gui.team_flags(name,ctf.players[name].team)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Do navigation
|
||||||
|
for tname, tab in pairs(ctf.gui.tabs) do
|
||||||
|
if fields[tname] then
|
||||||
|
ctf.gui.show(name, tname)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields.board then
|
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
|
||||||
ctf.gui.team_board(name,ctf.players[name].team)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if fields.diplo then
|
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
|
||||||
ctf.gui.team_dip(name,ctf.players[name].team)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
if fields.admin then
|
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
|
||||||
ctf.gui.team_settings(name,ctf.players[name].team)
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Todo: move callbacks
|
||||||
|
-- News page
|
||||||
if fields.clear then
|
if fields.clear then
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
||||||
ctf.team(ctf.players[name].team).log = {}
|
ctf.team(ctf.players[name].team).log = {}
|
||||||
ctf.save()
|
ctf.save()
|
||||||
ctf.gui.team_board(name,ctf.players[name].team)
|
ctf.gui.team_board(name, ctf.players[name].team)
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if fields.save and formname=="ctf:team_settings" then
|
|
||||||
|
-- Settings page
|
||||||
|
if fields.save and formname=="ctf:settings" then
|
||||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team then
|
||||||
ctf.gui.team_settings(name,ctf.players[name].team)
|
ctf.gui.team_settings(name, ctf.players[name].team)
|
||||||
end
|
end
|
||||||
if ctf and ctf.team(ctf.players[name].team) and ctf.team(ctf.players[name].team).data then
|
if ctf and ctf.team(ctf.players[name].team) and ctf.team(ctf.players[name].team).data then
|
||||||
if minetest.registered_items["ctf:flag_top_"..fields.color] then
|
if minetest.registered_items["ctf:flag_top_"..fields.color] then
|
||||||
@ -290,16 +311,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if formname=="ctf:board" then
|
if formname=="ctf:news" then
|
||||||
for key, field in pairs(fields) do
|
for key, field in pairs(fields) do
|
||||||
local ok, id = string.match(key, "btn_([yn])([0123456789]+)")
|
local ok, id = string.match(key, "btn_([yn])([0123456789]+)")
|
||||||
if ok and id then
|
if ok and id then
|
||||||
if ctf.player(name) and ctf.player(name).team and ctf.team(ctf.player(name).team) then
|
if ctf.player(name).team and ctf.team(ctf.player(name).team) then
|
||||||
if ok == "y" then
|
if ok == "y" then
|
||||||
ctf.diplo.set(ctf.player(name).team, ctf.team(ctf.player(name).team).log[tonumber(id)].team, ctf.team(ctf.player(name).team).log[tonumber(id)].msg)
|
ctf.diplo.set(ctf.player(name).team, ctf.team(ctf.player(name).team).log[tonumber(id)].team, ctf.team(ctf.player(name).team).log[tonumber(id)].msg)
|
||||||
ctf.post(ctf.player(name).team,{msg="You have accepted the "..ctf.team(ctf.player(name).team).log[tonumber(id)].msg.." request from "..ctf.team(ctf.player(name).team).log[tonumber(id)].team})
|
ctf.post(ctf.player(name).team,{msg="You have accepted the "..ctf.team(ctf.player(name).team).log[tonumber(id)].msg.." request from "..ctf.team(ctf.player(name).team).log[tonumber(id)].team})
|
||||||
@ -318,12 +338,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
|
-- Todo: fix security issue here
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if formname=="ctf:flags" then
|
if formname=="ctf:flags" then
|
||||||
for key, field in pairs(fields) do
|
for key, field in pairs(fields) do
|
||||||
local x,y,z = string.match(key, "goto_(%d+)_(%d+)_(%d+)")
|
local x,y,z = string.match(key, "goto_(%d+)_(%d+)_(%d+)")
|
||||||
if x and y and x then
|
if x and y and x then
|
||||||
player:setpos({x=x,y=y,z=z})
|
player:setpos({x=x, y=y, z=z})
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -332,7 +353,7 @@ end)
|
|||||||
|
|
||||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
if formname=="ctf:dip" then
|
if formname=="ctf:diplo" then
|
||||||
for key, field in pairs(fields) do
|
for key, field in pairs(fields) do
|
||||||
local newteam = string.match(key, "team_(.+)")
|
local newteam = string.match(key, "team_(.+)")
|
||||||
if newteam then
|
if newteam then
|
||||||
|
@ -108,18 +108,7 @@ minetest.register_chatcommand("team", {
|
|||||||
ctf.players[name].team and
|
ctf.players[name].team and
|
||||||
ctf.setting("gui")
|
ctf.setting("gui")
|
||||||
) then
|
) then
|
||||||
minetest.chat_send_player(name, "Showing the Team GUI")
|
ctf.gui.show(name)
|
||||||
if ctf.setting("team_gui_initial") == "news" and ctf.setting("news_gui") then
|
|
||||||
ctf.gui.team_board(name,ctf.players[name].team)
|
|
||||||
elseif ctf.setting("team_gui_initial") == "flags" and ctf.setting("flag_teleport_gui") then
|
|
||||||
ctf.gui.team_flags(name,ctf.players[name].team)
|
|
||||||
elseif ctf.setting("team_gui_initial") == "diplo" and ctf.setting("diplomacy") then
|
|
||||||
ctf.gui.team_dip(name,ctf.players[name].team)
|
|
||||||
elseif ctf.setting("team_gui_initial") == "admin" then
|
|
||||||
ctf.gui.team_settings(name,ctf.players[name].team)
|
|
||||||
elseif ctf.setting("news_gui") then
|
|
||||||
ctf.gui.team_board(name,ctf.players[name].team)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user