Merge branch 'multimap' into master
This commit is contained in:
commit
e93a19f075
29 changed files with 907 additions and 426 deletions
|
@ -7,7 +7,6 @@ end
|
|||
|
||||
dofile(minetest.get_modpath("ctf_match") .. "/matches.lua")
|
||||
dofile(minetest.get_modpath("ctf_match") .. "/buildtime.lua")
|
||||
dofile(minetest.get_modpath("ctf_match") .. "/reset.lua")
|
||||
dofile(minetest.get_modpath("ctf_match") .. "/chat.lua")
|
||||
dofile(minetest.get_modpath("ctf_match") .. "/vote.lua")
|
||||
|
||||
|
|
|
@ -36,65 +36,7 @@ function ctf_match.next()
|
|||
end
|
||||
|
||||
ctf.reset()
|
||||
-- Note: ctf.reset calls register_on_new_game, below.
|
||||
end
|
||||
|
||||
-- Check for winner
|
||||
local game_won = false
|
||||
function ctf_match.check_for_winner()
|
||||
local winner
|
||||
for name, team in pairs(ctf.teams) do
|
||||
if winner then
|
||||
return
|
||||
end
|
||||
winner = name
|
||||
end
|
||||
|
||||
-- There is a winner!
|
||||
if not game_won then
|
||||
game_won = true
|
||||
ctf.action("match", winner .. " won!")
|
||||
minetest.chat_send_all("Team " .. winner .. " won!")
|
||||
for i = 1, #ctf_match.registered_on_winner do
|
||||
ctf_match.registered_on_winner[i](winner)
|
||||
end
|
||||
minetest.after(2, function()
|
||||
game_won = false
|
||||
if ctf.setting("match") then
|
||||
ctf_match.next()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
function ctf_match.create_teams()
|
||||
local number = ctf.setting("match.teams")
|
||||
|
||||
for i = 1, number do
|
||||
print("Creating team #" .. i)
|
||||
local name = ctf.setting("match.team." .. i)
|
||||
local color = ctf.setting("match.team." .. i .. ".color")
|
||||
local pos = ctf.setting("match.team." .. i .. ".pos")
|
||||
local flag = minetest.string_to_pos(pos)
|
||||
|
||||
if name and color and pos and flag then
|
||||
print(" - Success in getting settings")
|
||||
ctf.team({
|
||||
name = name,
|
||||
color = color,
|
||||
add_team = true
|
||||
})
|
||||
|
||||
ctf_flag.add(name, flag)
|
||||
|
||||
minetest.after(0, function()
|
||||
ctf_flag.assert_flag(flag)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ctf.register_on_new_game(function()
|
||||
ctf_match.create_teams()
|
||||
|
||||
for i, player in pairs(minetest.get_connected_players()) do
|
||||
|
@ -125,7 +67,40 @@ ctf.register_on_new_game(function()
|
|||
if minetest.global_exists("chatplus") then
|
||||
chatplus.log("Next round!")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- Check for winner
|
||||
local game_won = false
|
||||
function ctf_match.check_for_winner()
|
||||
local winner
|
||||
for name, team in pairs(ctf.teams) do
|
||||
if winner then
|
||||
return
|
||||
end
|
||||
winner = name
|
||||
end
|
||||
|
||||
-- There is a winner!
|
||||
if not game_won then
|
||||
game_won = true
|
||||
ctf.action("match", winner .. " won!")
|
||||
minetest.chat_send_all("Team " .. winner .. " won!")
|
||||
for i = 1, #ctf_match.registered_on_winner do
|
||||
ctf_match.registered_on_winner[i](winner)
|
||||
end
|
||||
minetest.after(2, function()
|
||||
game_won = false
|
||||
if ctf.setting("match") then
|
||||
ctf_match.next()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- This is overriden by ctf_map
|
||||
function ctf_match.create_teams()
|
||||
error("Error! Unimplemented")
|
||||
end
|
||||
|
||||
ctf_flag.register_on_capture(function(attname, flag)
|
||||
if not ctf.setting("match.destroy_team") then
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
ctf.register_on_init(function()
|
||||
ctf._set("match.map_reset_limit", 0)
|
||||
end)
|
||||
|
||||
function ctf_match.next()
|
||||
for i = 1, #ctf_match.registered_on_new_match do
|
||||
ctf_match.registered_on_new_match[i]()
|
||||
end
|
||||
|
||||
local r = ctf.setting("match.map_reset_limit")
|
||||
if r > 0 then
|
||||
minetest.chat_send_all("Resetting the map, this may take a few moments...")
|
||||
minetest.after(0.5, function()
|
||||
minetest.delete_area(vector.new(-r, -r, -r), vector.new(r, r, r))
|
||||
|
||||
minetest.after(1, function()
|
||||
minetest.clear_objects()
|
||||
ctf.reset()
|
||||
if vote then
|
||||
vote.active = {}
|
||||
vote.queue = {}
|
||||
vote.update_all_hud()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
else
|
||||
ctf.reset()
|
||||
if vote then
|
||||
vote.active = {}
|
||||
vote.queue = {}
|
||||
vote.update_all_hud()
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue