Update with kingdoms_game version

previous to this will be quite outdated
This commit is contained in:
Elkien3 2017-10-19 08:28:29 -05:00
parent 64a762383c
commit f82495b539
4 changed files with 108 additions and 24 deletions

View File

@ -131,6 +131,8 @@ ctf.gui.register_tab("news", "News", function(name, tname)
result) result)
end) end)
local scroll_diplomacy = 0
local scroll_max = 0
-- Team interface -- Team interface
ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname) ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
local result = "" local result = ""
@ -150,7 +152,24 @@ ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
end end
result = result .. "label[1,1;Diplomacy from the perspective of " .. tname .. "]" 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 for i = 1, #data do
amount = i amount = i
local height = (i*1)+0.5 local height = (i*1)+0.5
@ -159,35 +178,37 @@ ctf.gui.register_tab("diplo", "Diplomacy", function(name, tname)
break break
end end
local L = i + scroll_diplomacy
result = result .. "background[1," .. height .. ";8.2,1;diplo_" .. 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_" .. result = result .. "button[1.25," .. height .. ";2,1;team_" ..
data[i].team .. ";" .. data[i].team .. "]" data[L].team .. ";" .. data[L].team .. "]"
result = result .. "label[3.75," .. height .. ";" .. data[i].state result = result .. "label[3.75," .. height .. ";" .. data[L].state
.. "]" .. "]"
if ctf.can_mod(name, tname) and ctf.player(name).team == tname then 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 not data[L].from and not data[L].to then
if data[i].state == "war" then if data[L].state == "war" then
result = result .. "button[7.5," .. height .. result = result .. "button[7.5," .. height ..
";1.5,1;peace_" .. data[i].team .. ";Peace]" ";1.5,1;peace_" .. data[L].team .. ";Peace]"
elseif data[i].state == "peace" then elseif data[L].state == "peace" then
result = result .. "button[6," .. height .. 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 .. result = result .. "button[7.5," .. height ..
";1.5,1;alli_" .. data[i].team .. ";Alliance]" ";1.5,1;alli_" .. data[L].team .. ";Alliance]"
elseif data[i].state == "alliance" then elseif data[L].state == "alliance" then
result = result .. "button[6," .. height .. result = result .. "button[6," .. height ..
";1.5,1;peace_" .. data[i].team .. ";Peace]" ";1.5,1;peace_" .. data[L].team .. ";Peace]"
end end
elseif data[i].from ~= nil then elseif data[L].from ~= nil then
result = result .. "label[6," .. height .. result = result .. "label[6," .. height ..
";request recieved]" ";request recieved]"
elseif data[i].to ~= nil then elseif data[L].to ~= nil then
result = result .. "label[5.5," .. height .. result = result .. "label[5.5," .. height ..
";request sent]" ";request sent]"
result = result .. "button[7.5," .. height .. 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 end
end end
@ -280,6 +301,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
local cur_team = nil
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()
local tplayer = ctf.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) local team = ctf.team(tname)
if not team or formname ~= "ctf:diplo" then if not team or formname ~= "ctf:diplo" then
cur_team = nil
return false return false
end 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 for key, field in pairs(fields) do
local tname2 = string.match(key, "team_(.+)") local tname2 = string.match(key, "team_(.+)")
if tname2 and ctf.team(tname2) then if tname2 and ctf.team(tname2) then
ctf.gui.show(name, "diplo", tname2) ctf.gui.show(name, "diplo", tname2)
cur_team = tname2
return true return true
end end
@ -325,8 +369,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
ctf.diplo.set(tname, tname2, "war") ctf.diplo.set(tname, tname2, "war")
ctf.post(tname, { ctf.post(tname, {
msg = "You have declared war on " .. tname2 }) msg = "You have declared war on " .. tname2 })
irc:say(tname .. "has declared war on " .. tname2 .. "!") irc:say(tname .. " has declared war on " .. tname2 .. "!")
minetest.chat_send_all(tname .. "has declared war on " .. tname2 .. "!") minetest.chat_send_all(tname .. " has declared war on " .. tname2 .. "!")
ctf.post(tname2, { ctf.post(tname2, {
msg = tname .. " has declared war on you" }) msg = tname .. " has declared war on you" })
ctf.gui.show(name, "diplo") ctf.gui.show(name, "diplo")

View File

@ -1,3 +1,4 @@
ctf ctf
chatplus? chatplus?
irc? irc?
inventory_plus

View File

@ -71,6 +71,9 @@ minetest.register_chatcommand("team", {
if value.auth then if value.auth then
minetest.chat_send_player(name, count .. ">> " .. value.name minetest.chat_send_player(name, count .. ">> " .. value.name
.. " (team owner)") .. " (team owner)")
elseif value.recruit then
minetest.chat_send_player(name, count .. ">> " .. value.name
.. " (team recruiter)")
else else
minetest.chat_send_player(name, count .. ">> " .. value.name) minetest.chat_send_player(name, count .. ">> " .. value.name)
end end
@ -83,6 +86,9 @@ minetest.register_chatcommand("team", {
if ctf.player(test).auth then if ctf.player(test).auth then
return true, test .. return true, test ..
" is in team " .. ctf.player(test).team.." (team owner)" " 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 else
return true, test .. return true, test ..
" is in team " .. ctf.player(test).team " is in team " .. ctf.player(test).team
@ -148,14 +154,14 @@ minetest.register_chatcommand("join", {
elseif ctf.player(param).team then elseif ctf.player(param).team then
return false, param .. " is already in a team!" return false, param .. " is already in a team!"
else 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 if ctf.join(param, team, false, name) then
return true, "Joined " .. param .. " to " .. team .. "!" return true, "Joined " .. param .. " to " .. team .. "!"
else else
return false, "Failed to join team!" return false, "Failed to join team!"
end end
else else
return false, "You are not the team owner!" return false, "You are not a team owner/recuiter!"
end end
end end
end end
@ -168,18 +174,21 @@ minetest.register_chatcommand("teamkick", {
if ctf.player(param).team ~= team then if ctf.player(param).team ~= team then
return false, param .. " is not in your team!" return false, param .. " is not in your team!"
else 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 if ctf.remove_player(param) then
return true, "Kicked " .. param .. " from " .. team .. "!" return true, "Kicked " .. param .. " from " .. team .. "!"
else else
return false, "Failed to kick " .. param.. "!" return false, "Failed to kick " .. param.. "!"
end end
else
return false, "You are not the team owner!"
end end
else
return false, "You are not the team owner!"
end end
end end
}) end})
minetest.register_chatcommand("teamleave", { minetest.register_chatcommand("teamleave", {
params = "none", params = "none",
description = "Leave your team", description = "Leave your team",
@ -276,11 +285,33 @@ minetest.register_chatcommand("team_owner", {
end 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", { minetest.register_chatcommand("post", {
params = "message", params = "message",
description = "Post a message on your team's message board", description = "Post a message on your team's message board",
func = function(name, param) 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 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 if not ctf.player(name).auth then
minetest.chat_send_player(name, "You do not own that team") minetest.chat_send_player(name, "You do not own that team")
@ -397,3 +428,11 @@ if minetest.global_exists("chatplus") then
return false return false
end) end)
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