Remove ctf GUI
This commit is contained in:
parent
e53732f41e
commit
9f05af002e
11 changed files with 0 additions and 517 deletions
|
@ -25,7 +25,6 @@ ctf.flag.alerts = true
|
|||
ctf.flag.drop_time = 300
|
||||
|
||||
ctf.allocate_mode = 3
|
||||
ctf.diplomacy = false
|
||||
ctf.players_can_change_team = false
|
||||
ctf.node_ownership = false
|
||||
ctf.friendly_fire = false
|
||||
|
@ -45,8 +44,3 @@ ctf.match.destroy_team = true
|
|||
ctf.match.reset_on_winner = true
|
||||
ctf.match.map_reset_limit = 200
|
||||
ctf.match.remove_player_on_leave = true
|
||||
|
||||
ctf.gui.tab.flags = false
|
||||
ctf.gui.tab.settings = false
|
||||
ctf.gui.tab.diplo = false
|
||||
ctf.gui.team.teleport_to_flag = false
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
-- diplo states: war, peace, alliance
|
||||
ctf.diplo = {
|
||||
diplo = {}
|
||||
}
|
||||
|
||||
ctf.register_on_load(function(table)
|
||||
ctf.diplo.diplo = table.diplo
|
||||
end)
|
||||
|
||||
function ctf.diplo.get(one,two)
|
||||
return "war"
|
||||
end
|
|
@ -1,212 +0,0 @@
|
|||
ctf.gui = {
|
||||
tabs = {}
|
||||
}
|
||||
|
||||
ctf.register_on_init(function()
|
||||
ctf._set("gui", true)
|
||||
ctf._set("gui.team", true)
|
||||
ctf._set("gui.team.initial", "news")
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
if ctf._defsettings and ctf._defsettings["gui.tab." .. name] == nil then
|
||||
ctf._set("gui.tab." .. name, true)
|
||||
end
|
||||
end
|
||||
|
||||
function ctf.gui.show(name, tab, tname)
|
||||
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 ctf.team(tname) then
|
||||
tname = ctf.player(name).team
|
||||
end
|
||||
|
||||
if ctf.team(tname) then
|
||||
ctf.action("gui", name .. " views " .. tname .. "'s " .. tab .. " page")
|
||||
ctf.gui.tabs[tab].func(name, tname)
|
||||
else
|
||||
ctf.log("gui", "Invalid team given to ctf.gui.show")
|
||||
end
|
||||
end
|
||||
|
||||
-- Get tab buttons
|
||||
function ctf.gui.get_tabs(name, tname)
|
||||
local result = ""
|
||||
local id = 1
|
||||
local function addtab(name,text)
|
||||
result = result .. "button[" .. (id*2-1) .. ",0;2,1;" .. name .. ";" .. text .. "]"
|
||||
id = id + 1
|
||||
end
|
||||
|
||||
for name, tab in pairs(ctf.gui.tabs) do
|
||||
if ctf.setting("gui.tab." .. name) then
|
||||
addtab(name, tab.title)
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- Team interface
|
||||
ctf.gui.register_tab("news", "News", function(name, tname)
|
||||
local result = ""
|
||||
local team = ctf.team(tname).log
|
||||
|
||||
if not team then
|
||||
team = {}
|
||||
end
|
||||
|
||||
local amount = 0
|
||||
|
||||
for i = 1, #team do
|
||||
if team[i].type == "request" then
|
||||
if ctf.can_mod(name, tname) then
|
||||
amount = amount + 2
|
||||
local height = (amount*0.5) + 0.5
|
||||
amount = amount + 1
|
||||
|
||||
if team[i].mode == "diplo" then
|
||||
result = result .. "background[0.5," .. height .. ";8.3,1;diplo_" .. team[i].msg .. ".png]"
|
||||
if team[i].msg == "alliance" then
|
||||
result = result .. "label[1," .. height .. ";" ..
|
||||
team[i].team .. " offers an " ..
|
||||
minetest.formspec_escape(team[i].msg) .. " treaty]"
|
||||
else
|
||||
result = result .. "label[1," .. height .. ";" ..
|
||||
team[i].team .. " offers a " ..
|
||||
minetest.formspec_escape(team[i].msg) .. " treaty]"
|
||||
end
|
||||
result = result .. "button[6," .. height .. ";1,1;btn_y" .. i .. ";Yes]"
|
||||
result = result .. "button[7," .. height .. ";1,1;btn_n" .. i .. ";No]"
|
||||
else
|
||||
result = result .. "label[0.5," .. height .. ";RANDOM REQUEST TYPE]"
|
||||
end
|
||||
end
|
||||
else
|
||||
amount = amount + 1
|
||||
local height = (amount*0.5) + 0.5
|
||||
|
||||
if height > 5 then
|
||||
break
|
||||
end
|
||||
|
||||
result = result .. "label[0.5," .. height .. ";" ..
|
||||
minetest.formspec_escape(team[i].msg) .. "]"
|
||||
end
|
||||
end
|
||||
|
||||
if ctf.can_mod(name, tname) then
|
||||
result = result .. "button[4,6;2,1;clear;Clear all]"
|
||||
end
|
||||
|
||||
if amount == 0 then
|
||||
result = "label[0.5,1;Welcome to the news panel]" ..
|
||||
"label[0.5,1.5;News such as attacks will appear here]"
|
||||
end
|
||||
|
||||
minetest.show_formspec(name, "ctf:news",
|
||||
"size[10,7]" ..
|
||||
ctf.gui.get_tabs(name, tname) ..
|
||||
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
|
||||
return false
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if not formspec_is_ctf_tab(formname) then
|
||||
return false
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
local tplayer = ctf.player(name)
|
||||
local tname = tplayer.team
|
||||
local team = ctf.team(tname)
|
||||
|
||||
if not team then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Do navigation
|
||||
for tabname, tab in pairs(ctf.gui.tabs) do
|
||||
if fields[tabname] then
|
||||
ctf.gui.show(name, tabname)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
-- Todo: move callbacks
|
||||
-- News page
|
||||
if fields.clear then
|
||||
team.log = {}
|
||||
ctf.gui.show(name, "news")
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local name = player:get_player_name()
|
||||
local tplayer = ctf.player(name)
|
||||
local tname = tplayer.team
|
||||
local team = ctf.team(tname)
|
||||
|
||||
if not team then
|
||||
return false
|
||||
end
|
||||
|
||||
if formname == "ctf:news" then
|
||||
for key, field in pairs(fields) do
|
||||
local ok, id = string.match(key, "btn_([yn])([0123456789]+)")
|
||||
if ok and id then
|
||||
if ok == "y" then
|
||||
ctf.diplo.set(tname, team.log[tonumber(id)].team, team.log[tonumber(id)].msg)
|
||||
|
||||
-- Post to acceptor's log
|
||||
ctf.post(tname, {
|
||||
msg = "You have accepted the " ..
|
||||
team.log[tonumber(id)].msg .. " request from " ..
|
||||
team.log[tonumber(id)].team })
|
||||
|
||||
-- Post to request's log
|
||||
ctf.post(team.log[tonumber(id)].team, {
|
||||
msg = tname .. " has accepted your " ..
|
||||
team.log[tonumber(id)].msg .. " request" })
|
||||
|
||||
id = id + 1
|
||||
end
|
||||
|
||||
table.remove(team.log, id)
|
||||
ctf.gui.show(name, "news")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
|
@ -16,8 +16,6 @@ minetest.register_privilege("ctf_admin", {
|
|||
-- Modules
|
||||
dofile(minetest.get_modpath("ctf") .. "/core.lua")
|
||||
dofile(minetest.get_modpath("ctf") .. "/teams.lua")
|
||||
dofile(minetest.get_modpath("ctf") .. "/diplomacy.lua")
|
||||
dofile(minetest.get_modpath("ctf") .. "/gui.lua")
|
||||
dofile(minetest.get_modpath("ctf") .. "/hud.lua")
|
||||
|
||||
-- Init
|
||||
|
|
|
@ -183,20 +183,6 @@ minetest.register_chatcommand("team", {
|
|||
minetest.chat_send_player(name, "'"..param.."' is an invalid parameter to /team")
|
||||
team_console_help(name)
|
||||
end
|
||||
if ctf.setting("gui") then
|
||||
if (ctf and
|
||||
ctf.players and
|
||||
ctf.players[name] and
|
||||
ctf.players[name].team) then
|
||||
print("showing")
|
||||
ctf.gui.show(name)
|
||||
return true, "Showing the team window"
|
||||
else
|
||||
return false, "You're not part of a team!"
|
||||
end
|
||||
else
|
||||
return false, "GUI is disabled!"
|
||||
end
|
||||
end
|
||||
return false, "Nothing could be done"
|
||||
end
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
|
||||
ctf.gui.register_tab("settings", "Settings", function(name, team)
|
||||
local color = ""
|
||||
if ctf.team(team).data.color then
|
||||
color = ctf.team(team).data.color
|
||||
end
|
||||
|
||||
local result = "field[3,2;4,1;color;Team Color;" .. color .. "]" ..
|
||||
"button[4,6;2,1;save;Save]"
|
||||
|
||||
|
||||
if not ctf.can_mod(name,team) then
|
||||
result = "label[0.5,1;You do not own this team!"
|
||||
end
|
||||
|
||||
minetest.show_formspec(name, "ctf:settings",
|
||||
"size[10,7]" ..
|
||||
ctf.gui.get_tabs(name, team) ..
|
||||
result
|
||||
)
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if formname ~= "ctf:settings" then
|
||||
return false
|
||||
end
|
||||
|
||||
-- Settings page
|
||||
if fields.save then
|
||||
local name = player:get_player_name()
|
||||
local pdata = ctf.player(name)
|
||||
local team = ctf.team(pdata.team)
|
||||
|
||||
ctf.gui.show(name, "settings")
|
||||
if team and ctf.can_mod(name, pdata.team) then
|
||||
if ctf.flag_colors[fields.color] then
|
||||
team.data.color = fields.color
|
||||
|
||||
minetest.chat_send_player(name, "Team color set to " .. fields.color)
|
||||
else
|
||||
local colors = ""
|
||||
for color, code in pairs(ctf.flag_colors) do
|
||||
if colors ~= "" then
|
||||
colors = colors .. ", "
|
||||
end
|
||||
colors = colors .. color
|
||||
end
|
||||
minetest.chat_send_player(name, "Color " .. fields.color ..
|
||||
" does not exist! Available: " .. colors)
|
||||
end
|
||||
elseif team then
|
||||
minetest.chat_send_player(name, "You don't have the rights to change settings.")
|
||||
else
|
||||
minetest.chat_send_player(name, "You don't appear to be in a team")
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
end)
|
|
@ -28,4 +28,3 @@ ctf.register_on_init(function()
|
|||
end)
|
||||
|
||||
dofile(minetest.get_modpath("ctf_colors") .. "/hud.lua")
|
||||
dofile(minetest.get_modpath("ctf_colors") .. "/gui.lua")
|
||||
|
|
|
@ -114,7 +114,6 @@ ctf_flag = {
|
|||
flag.claimed = nil
|
||||
end
|
||||
end
|
||||
ctf.gui.flag_board(name, pos)
|
||||
end,
|
||||
on_punch = function(pos, node, puncher)
|
||||
local name = puncher:get_player_name()
|
||||
|
@ -150,15 +149,6 @@ ctf_flag = {
|
|||
ctf_flag._flagret(name)
|
||||
end
|
||||
else
|
||||
-- Clicked on another team's flag
|
||||
local diplo = ctf.diplo.get(team, ctf.player(name).team) or
|
||||
ctf.setting("default_diplo_state")
|
||||
|
||||
if diplo ~= "war" then
|
||||
minetest.chat_send_player(name, "You are at peace with this team!")
|
||||
return
|
||||
end
|
||||
|
||||
do_capture(name, flag)
|
||||
end
|
||||
else
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
-- Team interface
|
||||
ctf.gui.register_tab("flags", "Flags", function(name, team)
|
||||
local result = ""
|
||||
local t = ctf.team(team)
|
||||
|
||||
if not t then
|
||||
return
|
||||
end
|
||||
|
||||
local x = 1
|
||||
local y = 2
|
||||
result = result .. "label[1,1;Click a flag button to go there]"
|
||||
|
||||
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+)")
|
||||
|
||||
result = result ..
|
||||
"button[" .. x .. "," .. y .. ";2,1;goto_"
|
||||
..f.x.."_"..f.y.."_"..f.z..";"
|
||||
|
||||
result = result .. "Spawn]"
|
||||
x = x + 2
|
||||
end
|
||||
|
||||
for i=1, #t.flags do
|
||||
local f = t.flags[i]
|
||||
|
||||
if x > 8 then
|
||||
x = 1
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
if y > 6 then
|
||||
break
|
||||
end
|
||||
|
||||
result = result ..
|
||||
"button[" .. x .. "," .. y .. ";2,1;goto_"
|
||||
..f.x.."_"..f.y.."_"..f.z..";"
|
||||
|
||||
if f.name then
|
||||
result = result .. f.name .. "]"
|
||||
else
|
||||
result = result .. "("..f.x..","..f.y..","..f.z..")]"
|
||||
end
|
||||
|
||||
x = x + 2
|
||||
end
|
||||
|
||||
minetest.show_formspec(name, "ctf:flags",
|
||||
"size[10,7]"..
|
||||
ctf.gui.get_tabs(name,team)..
|
||||
result)
|
||||
end)
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
-- Todo: fix security issue here
|
||||
-- local name = player:get_player_name()
|
||||
-- if formname == "ctf:flags" then
|
||||
-- for key, field in pairs(fields) do
|
||||
-- local x,y,z = string.match(key, "goto_([%d-]+)_([%d-]+)_([%d-]+)")
|
||||
-- if x and y and z then
|
||||
-- player:setpos({ x=tonumber(x), y=tonumber(y), z=tonumber(z) })
|
||||
-- return true
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
end)
|
||||
|
||||
-- Flag interface
|
||||
function ctf.gui.flag_board(name, pos)
|
||||
local flag = ctf_flag.get(pos)
|
||||
if not flag then
|
||||
return
|
||||
end
|
||||
|
||||
local team = flag.team
|
||||
if not team then
|
||||
return
|
||||
end
|
||||
|
||||
if not ctf.can_mod(name, team) then
|
||||
if ctf.player(name).team and ctf.player(name).team == team then
|
||||
ctf.gui.show(name)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
ctf.log("gui", name .. " views flag board")
|
||||
|
||||
local flag_name = flag.name
|
||||
|
||||
if not ctf.setting("flag.names") then
|
||||
flag.name = nil
|
||||
return
|
||||
end
|
||||
|
||||
if not ctf.setting("gui") then
|
||||
return
|
||||
end
|
||||
|
||||
if not flag_name then
|
||||
flag_name = ""
|
||||
end
|
||||
|
||||
if not ctf.gui.flag_data then
|
||||
ctf.gui.flag_data = {}
|
||||
end
|
||||
|
||||
ctf.gui.flag_data[name] = {pos=pos}
|
||||
|
||||
minetest.show_formspec(name, "ctf:flag_board",
|
||||
"size[6,3]"..
|
||||
"field[1,1;4,1;flag_name;Flag Name;"..flag_name.."]"..
|
||||
"button_exit[1,2;2,1;save;Save]"..
|
||||
"button_exit[3,2;2,1;delete;Delete]"
|
||||
)
|
||||
end
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if not formname=="ctf:flag_board" then
|
||||
return false
|
||||
end
|
||||
|
||||
if fields.save and fields.flag_name then
|
||||
local flag = ctf_flag.get(ctf.gui.flag_data[name].pos)
|
||||
if not flag then
|
||||
return false
|
||||
end
|
||||
|
||||
local team = flag.team
|
||||
if not team then
|
||||
return false
|
||||
end
|
||||
|
||||
if ctf.can_mod(name,team) == false then
|
||||
return false
|
||||
end
|
||||
|
||||
local flag_name = flag.name
|
||||
if not flag_name then
|
||||
flag_name = ""
|
||||
end
|
||||
|
||||
flag.name = fields.flag_name
|
||||
|
||||
local msg = flag_name.." was renamed to "..fields.flag_name
|
||||
|
||||
if flag_name=="" then
|
||||
msg = "A flag was named "..fields.flag_name.." at ("..ctf.gui.flag_data[name].pos.x..","..ctf.gui.flag_data[name].pos.z..")"
|
||||
end
|
||||
|
||||
ctf.post(team,{msg=msg,icon="flag_info"})
|
||||
|
||||
return true
|
||||
elseif fields.delete then
|
||||
local pos = ctf.gui.flag_data[name].pos
|
||||
|
||||
local flag = ctf_flag.get(ctf.gui.flag_data[name].pos)
|
||||
|
||||
if not flag then
|
||||
return
|
||||
end
|
||||
|
||||
local team = flag.team
|
||||
if not team then
|
||||
return
|
||||
end
|
||||
|
||||
if ctf.can_mod(name,team) == false then
|
||||
return false
|
||||
end
|
||||
|
||||
ctf_flag.delete(team,pos)
|
||||
|
||||
minetest.set_node(pos,{name="air"})
|
||||
pos.y=pos.y+1
|
||||
minetest.set_node(pos,{name="air"})
|
||||
player:get_inventory():add_item("main", "ctf_flag:flag")
|
||||
|
||||
return true
|
||||
end
|
||||
end)
|
|
@ -12,8 +12,6 @@ ctf.register_on_init(function()
|
|||
ctf._set("flag.crafting", false)
|
||||
ctf._set("flag.alerts", true)
|
||||
ctf._set("flag.alerts.neutral_alert", true)
|
||||
ctf._set("gui.team.teleport_to_flag", true)
|
||||
ctf._set("gui.team.teleport_to_spawn", false)
|
||||
end)
|
||||
|
||||
minetest.register_privilege("ctf_place_flag", {
|
||||
|
@ -21,7 +19,6 @@ minetest.register_privilege("ctf_place_flag", {
|
|||
})
|
||||
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/hud.lua")
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/gui.lua")
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/flag_func.lua")
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/api.lua")
|
||||
dofile(minetest.get_modpath("ctf_flag") .. "/flags.lua")
|
||||
|
|
|
@ -50,17 +50,3 @@ ctf.teams = {
|
|||
flag_name = "Capital" -- human readable name
|
||||
}
|
||||
```
|
||||
|
||||
## Diplomacy
|
||||
|
||||
```lua
|
||||
ctf.diplo.diplo = {
|
||||
(diplo_table), (diplo_table)
|
||||
}
|
||||
|
||||
(diplo_table) = {
|
||||
one = "teamname1",
|
||||
two = "teamname2",
|
||||
state = "war" / "peace" / "alliance"
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue