parent
64a762383c
commit
f82495b539
78
ctf/gui.lua
78
ctf/gui.lua
|
@ -131,6 +131,8 @@ ctf.gui.register_tab("news", "News", function(name, tname)
|
|||
result)
|
||||
end)
|
||||
|
||||
local scroll_diplomacy = 0
|
||||
local scroll_max = 0
|
||||
-- Team interface
|
||||
ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
|
||||
local result = ""
|
||||
|
@ -150,7 +152,24 @@ ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
|
|||
end
|
||||
|
||||
result = result .. "label[1,1;Diplomacy from the perspective of " .. tname .. "]"
|
||||
|
||||
|
||||
scroll_max = 0
|
||||
for i = 1, #data do
|
||||
scroll_max = i
|
||||
end
|
||||
scroll_max = scroll_max - 5
|
||||
|
||||
if scroll_diplomacy > (scroll_max+5) then
|
||||
scroll_diplomacy = (scroll_max+5)
|
||||
end
|
||||
|
||||
if scroll_diplomacy > 0 then
|
||||
result = result .. "button[9.2,0.44;1,3;scroll_up;Up]"
|
||||
end
|
||||
if scroll_diplomacy <= scroll_max then
|
||||
result = result .. "button[9.2,3.8;1,3;scroll_down;Down]"
|
||||
end
|
||||
|
||||
for i = 1, #data do
|
||||
amount = i
|
||||
local height = (i*1)+0.5
|
||||
|
@ -159,35 +178,37 @@ ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
|
|||
break
|
||||
end
|
||||
|
||||
local L = i + scroll_diplomacy
|
||||
|
||||
result = result .. "background[1," .. height .. ";8.2,1;diplo_" ..
|
||||
data[i].state .. ".png]"
|
||||
data[L].state .. ".png]"
|
||||
result = result .. "button[1.25," .. height .. ";2,1;team_" ..
|
||||
data[i].team .. ";" .. data[i].team .. "]"
|
||||
result = result .. "label[3.75," .. height .. ";" .. data[i].state
|
||||
data[L].team .. ";" .. data[L].team .. "]"
|
||||
result = result .. "label[3.75," .. height .. ";" .. data[L].state
|
||||
.. "]"
|
||||
|
||||
if ctf.can_mod(name, tname) and ctf.player(name).team == tname then
|
||||
if not data[i].from and not data[i].to then
|
||||
if data[i].state == "war" then
|
||||
if not data[L].from and not data[L].to then
|
||||
if data[L].state == "war" then
|
||||
result = result .. "button[7.5," .. height ..
|
||||
";1.5,1;peace_" .. data[i].team .. ";Peace]"
|
||||
elseif data[i].state == "peace" then
|
||||
";1.5,1;peace_" .. data[L].team .. ";Peace]"
|
||||
elseif data[L].state == "peace" then
|
||||
result = result .. "button[6," .. height ..
|
||||
";1.5,1;war_" .. data[i].team .. ";War]"
|
||||
";1.5,1;war_" .. data[L].team .. ";War]"
|
||||
result = result .. "button[7.5," .. height ..
|
||||
";1.5,1;alli_" .. data[i].team .. ";Alliance]"
|
||||
elseif data[i].state == "alliance" then
|
||||
";1.5,1;alli_" .. data[L].team .. ";Alliance]"
|
||||
elseif data[L].state == "alliance" then
|
||||
result = result .. "button[6," .. height ..
|
||||
";1.5,1;peace_" .. data[i].team .. ";Peace]"
|
||||
";1.5,1;peace_" .. data[L].team .. ";Peace]"
|
||||
end
|
||||
elseif data[i].from ~= nil then
|
||||
elseif data[L].from ~= nil then
|
||||
result = result .. "label[6," .. height ..
|
||||
";request recieved]"
|
||||
elseif data[i].to ~= nil then
|
||||
elseif data[L].to ~= nil then
|
||||
result = result .. "label[5.5," .. height ..
|
||||
";request sent]"
|
||||
result = result .. "button[7.5," .. height ..
|
||||
";1.5,1;cancel_" .. data[i].team .. ";Cancel]"
|
||||
";1.5,1;cancel_" .. data[L].team .. ";Cancel]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -280,6 +301,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
end
|
||||
end)
|
||||
|
||||
local cur_team = nil
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local name = player:get_player_name()
|
||||
local tplayer = ctf.player(name)
|
||||
|
@ -287,13 +309,35 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
local team = ctf.team(tname)
|
||||
|
||||
if not team or formname ~= "ctf:diplo" then
|
||||
cur_team = nil
|
||||
return false
|
||||
end
|
||||
|
||||
if cur_team == nil then
|
||||
cur_team = tname
|
||||
end
|
||||
if fields.scroll_up then
|
||||
if scroll_diplomacy > 0 then
|
||||
scroll_diplomacy = scroll_diplomacy - 1
|
||||
else
|
||||
scroll_diplomacy = 0
|
||||
end
|
||||
ctf.gui.show(name, "diplo", cur_team)
|
||||
end
|
||||
if fields.scroll_down then
|
||||
if scroll_diplomacy < (scroll_max+5) then
|
||||
scroll_diplomacy = scroll_diplomacy + 1
|
||||
else
|
||||
scroll_diplomacy = scroll_max
|
||||
end
|
||||
ctf.gui.show(name, "diplo", cur_team)
|
||||
end
|
||||
|
||||
for key, field in pairs(fields) do
|
||||
local tname2 = string.match(key, "team_(.+)")
|
||||
if tname2 and ctf.team(tname2) then
|
||||
ctf.gui.show(name, "diplo", tname2)
|
||||
cur_team = tname2
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -325,8 +369,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
ctf.diplo.set(tname, tname2, "war")
|
||||
ctf.post(tname, {
|
||||
msg = "You have declared war on " .. tname2 })
|
||||
irc:say(tname .. "has declared war on " .. tname2 .. "!")
|
||||
minetest.chat_send_all(tname .. "has declared war on " .. tname2 .. "!")
|
||||
irc:say(tname .. " has declared war on " .. tname2 .. "!")
|
||||
minetest.chat_send_all(tname .. " has declared war on " .. tname2 .. "!")
|
||||
ctf.post(tname2, {
|
||||
msg = tname .. " has declared war on you" })
|
||||
ctf.gui.show(name, "diplo")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
ctf
|
||||
chatplus?
|
||||
irc?
|
||||
inventory_plus
|
|
@ -71,6 +71,9 @@ minetest.register_chatcommand("team", {
|
|||
if value.auth then
|
||||
minetest.chat_send_player(name, count .. ">> " .. value.name
|
||||
.. " (team owner)")
|
||||
elseif value.recruit then
|
||||
minetest.chat_send_player(name, count .. ">> " .. value.name
|
||||
.. " (team recruiter)")
|
||||
else
|
||||
minetest.chat_send_player(name, count .. ">> " .. value.name)
|
||||
end
|
||||
|
@ -83,6 +86,9 @@ minetest.register_chatcommand("team", {
|
|||
if ctf.player(test).auth then
|
||||
return true, test ..
|
||||
" is in team " .. ctf.player(test).team.." (team owner)"
|
||||
elseif ctf.player(test).recruit then
|
||||
return true, test ..
|
||||
" is in team " .. ctf.player(test).team.." (team recruiter)"
|
||||
else
|
||||
return true, test ..
|
||||
" is in team " .. ctf.player(test).team
|
||||
|
@ -148,14 +154,14 @@ minetest.register_chatcommand("join", {
|
|||
elseif ctf.player(param).team then
|
||||
return false, param .. " is already in a team!"
|
||||
else
|
||||
if ctf.player(name).auth then
|
||||
if ctf.player(name).auth or ctf.player(name).recruit then
|
||||
if ctf.join(param, team, false, name) then
|
||||
return true, "Joined " .. param .. " to " .. team .. "!"
|
||||
else
|
||||
return false, "Failed to join team!"
|
||||
end
|
||||
else
|
||||
return false, "You are not the team owner!"
|
||||
return false, "You are not a team owner/recuiter!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -168,18 +174,21 @@ minetest.register_chatcommand("teamkick", {
|
|||
if ctf.player(param).team ~= team then
|
||||
return false, param .. " is not in your team!"
|
||||
else
|
||||
if ctf.player(name).auth then
|
||||
if ctf.player(name).auth or ctf.player(name).recruit then
|
||||
if ctf.player(param).auth or ctf.player(param).recuiter then
|
||||
return false, param.. " is a team owner or recruiter!"
|
||||
else
|
||||
if ctf.remove_player(param) then
|
||||
return true, "Kicked " .. param .. " from " .. team .. "!"
|
||||
else
|
||||
return false, "Failed to kick " .. param.. "!"
|
||||
end
|
||||
else
|
||||
return false, "You are not the team owner!"
|
||||
end
|
||||
else
|
||||
return false, "You are not the team owner!"
|
||||
end
|
||||
end
|
||||
})
|
||||
end})
|
||||
minetest.register_chatcommand("teamleave", {
|
||||
params = "none",
|
||||
description = "Leave your team",
|
||||
|
@ -276,11 +285,33 @@ minetest.register_chatcommand("team_owner", {
|
|||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("team_recruiter", {
|
||||
params = "player name",
|
||||
description = "Make player able to recruit",
|
||||
func = function(name, param)
|
||||
if ctf.player(name).auth or minetest.get_player_privs(name).ctf_admin then
|
||||
if ctf and ctf.players and ctf.player(param) and ctf.player(param).team and ctf.team(ctf.player(param).team) then
|
||||
if ctf.player(param).recruit == true then
|
||||
ctf.player(param).recruit = false
|
||||
return true, param.." was downgraded from team recruiter status"
|
||||
else
|
||||
ctf.player(param).recruit = true
|
||||
return true, param.." was upgraded to a recruiter of "..ctf.player(name).team
|
||||
end
|
||||
ctf.needs_save = true
|
||||
else
|
||||
return false, "Unable to do that :/ "..param.." does not exist, or is not part of a valid team."
|
||||
end
|
||||
else
|
||||
return false, "You are not the team owner!"
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("post", {
|
||||
params = "message",
|
||||
description = "Post a message on your team's message board",
|
||||
func = function(name, param)
|
||||
|
||||
if ctf and ctf.players and ctf.players[name] and ctf.players[name].team and ctf.teams[ctf.players[name].team] then
|
||||
if not ctf.player(name).auth then
|
||||
minetest.chat_send_player(name, "You do not own that team")
|
||||
|
@ -397,3 +428,11 @@ if minetest.global_exists("chatplus") then
|
|||
return false
|
||||
end)
|
||||
end
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
inventory_plus.register_button(player,"ctf", "ctf")
|
||||
end)
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if fields.ctf then
|
||||
ctf.gui.show(player:get_player_name())
|
||||
end
|
||||
end)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 438 B |
Loading…
Reference in New Issue