Setting changes

This commit is contained in:
rubenwardy 2015-07-12 14:43:03 +01:00
parent 909c5e825b
commit c29bce03c6
6 changed files with 204 additions and 168 deletions

View File

@ -1,64 +1,64 @@
# Whether teams own the nodes around their flag
#ctf_node_ownership = true
#ctf_flag_protect_distance = 25
#ctf.node_ownership = true
#ctf.flag_protect_distance = 25
# Can teams have multiple flags?
#ctf_multiple_flags = true
#ctf.multiple_flags = true
# Whether flags need to be taken to other teams flag to win
#ctf_flag_capture_take = false
#ctf.flag_capture_take = false
# Are GUIs enabled
#ctf_gui = true
#ctf.gui = true
# Is the HUD enabled
#ctf_hud = true
#ctf.hud = true
# Team GUI on /team
#ctf_team_gui = true
#ctf.team_gui = true
# Default tab when opening Team GUI
# news
# flags
# diplo
# admin
#ctf_team_gui_initial = news
#ctf.team_gui_initial = news
# Enable tabs in Team GUI
#ctf_flag_teleport_gui = true
#ctf_news_gui = true
#ctf_diplomacy = true
#ctf.flag_teleport_gui = true
#ctf.news_gui = true
#ctf.diplomacy = true
# Show the spawn as a target in flag teleport Team GUI
#ctf_spawn_in_flag_teleport_gui = false
#ctf.spawn_in_flag_teleport_gui = false
# Can flags have names?
#ctf_flag_names = true
#ctf.flag_names = true
# Do teams have their own chat channel?
#ctf_team_channel = true
#ctf.team_channel = true
# Can players chat with other teams on /all. If team_channel is disabled, this setting does nothing.
#ctf_global_channel = true
#ctf.global_channel = true
# Can players change teams using /join?
#ctf_players_can_change_team",true)
#ctf.players_can_change_team",true)
# How are players allocated to teams?
# 0: none,
# 1: random,
# 2: one of first two largest groups,
# 3 smallest group
#ctf_allocate_mode = 0
#ctf.allocate_mode = 0
# Maximum number in team, obeyed by allocation and /join. Admins don't obey this
#ctf_maximum_in_team = -1
#ctf.maximum_in_team = -1
# The default Diplomacy state (if diplomacy is enabled)
# war
# peace
# alliance
#ctf_default_diplo_state = war
#ctf.default_diplo_state = war
# Chatplus distance - how far players can hear each other
#ctf_chatplus_distance = -1
#ctf.chatplus_distance = -1

View File

@ -6,6 +6,10 @@ ctf.registered_on_save = {}
function ctf.register_on_save(func)
table.insert(ctf.registered_on_save, func)
end
ctf.registered_on_init = {}
function ctf.register_on_init(func)
table.insert(ctf.registered_on_init, func)
end
function ctf.error(area, msg)
minetest.log("error", "CTF::" .. area .. " - " ..msg)
@ -36,22 +40,24 @@ function ctf.init()
-- Settings: Feature enabling
ctf.log("init", "Creating Default Settings")
-- Settings: Flags and Territory
ctf._set("node_ownership", true)
ctf._set("multiple_flags", true)
ctf._set("flag_capture_take", false)
ctf._set("flag_names", true)
-- Settings: User Interface
ctf._set("gui", 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)
ctf._set("diplomacy", true)
ctf._set("flag_names", true)
ctf._set("team_channel", true)
ctf._set("global_channel", true)
ctf._set("players_can_change_team", true)
-- Settings: Teams
ctf._set("diplomacy", true)
ctf._set("players_can_change_team", true)
ctf._set("allocate_mode", 0)
ctf._set("maximum_in_team", -1)
ctf._set("default_diplo_state", "war")
@ -60,6 +66,10 @@ function ctf.init()
ctf._set("flag_protect_distance", 25)
ctf._set("team_gui_initial", "news")
for i = 1, #ctf.registered_on_init do
ctf.registered_on_init[i]()
end
ctf.load()
ctf.log("init", "Done!")
@ -69,13 +79,18 @@ end
function ctf._set(setting, default)
ctf._defsettings[setting] = default
if minetest.setting_get("ctf_"..setting) then
if minetest.setting_get("ctf."..setting) then
ctf.log("init", "- " .. setting .. ": " .. minetest.setting_get("ctf."..setting))
elseif minetest.setting_get("ctf_"..setting) then
ctf.log("init", "- " .. setting .. ": " .. minetest.setting_get("ctf_"..setting))
ctf.warning("init", "deprecated setting ctf_"..setting..
" used, use ctf."..setting.." instead.")
end
end
function ctf.setting(name)
local set = minetest.setting_get("ctf_"..name)
local set = minetest.setting_get("ctf."..name) or
minetest.setting_get("ctf_"..name)
local dset = ctf._defsettings[name]
if set ~= nil then
if type(dset) == "number" then

View File

@ -18,7 +18,8 @@ function ctf.diplo.get(one,two)
for i = 1, #ctf.diplo.diplo do
local dip = ctf.diplo.diplo[i]
if (dip.one == one and dip.two == two) or (dip.one == two and dip.two == one) then
if (dip.one == one and dip.two == two) or
(dip.one == two and dip.two == one) then
return dip.state
end
end
@ -27,20 +28,21 @@ function ctf.diplo.get(one,two)
end
function ctf.diplo.set(one, two, state)
if not ctf.diplo.diplo then
ctf.diplo.diplo = {}
else
if ctf.diplo.diplo then
-- Check the table for an existing diplo state
for i = 1, #ctf.diplo.diplo do
local dip = ctf.diplo.diplo[i]
if (dip.one == one and dip.two == two) or (dip.one == two and dip.two == one) then
if (dip.one == one and dip.two == two) or
(dip.one == two and dip.two == one) then
dip.state = state
return
end
end
else
ctf.diplo.diplo = {}
end
table.insert(ctf.diplo.diplo,{one=one,two=two,state=state})
return
end
function ctf.diplo.check_requests(one, two)
@ -51,7 +53,9 @@ function ctf.diplo.check_requests(one,two)
end
for i=1,#team.log do
if team.log[i].team == one and team.log[i].type=="request" and team.log[i].mode=="diplo" then
if team.log[i].team == one and
team.log[i].type == "request" and
team.log[i].mode == "diplo" then
return team.log[i].msg
end
end
@ -67,7 +71,9 @@ function ctf.diplo.cancel_requests(one,two)
end
for i=1,#team.log do
if team.log[i].team == one and team.log[i].type=="request" and team.log[i].mode=="diplo" then
if team.log[i].team == one and
team.log[i].type == "request" and
team.log[i].mode == "diplo" then
table.remove(team.log,i)
return
end

View File

@ -1,3 +1,10 @@
function init()
-- Settings: Chat
ctf._set("team_channel", true)
ctf._set("global_channel", true)
end
init()
local function team_console_help(name)
minetest.chat_send_player(name,"Try:", false)
minetest.chat_send_player(name,"/team - show team panel", false)

View File

@ -1,3 +1,9 @@
function init()
ctf._set("turrets", true)
end
init()
if ctf.setting("turrets") then
ARROW_DAMAGE = 2
ARROW_VELOCITY = 2
minetest.register_node("ctf_turret:turret", {
@ -137,3 +143,4 @@ minetest.register_craft({
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"}
}
})
end

View File

@ -11,6 +11,7 @@ minetest.register_alias("mapgen_jungletree", "default:jungletree")
minetest.register_alias("mapgen_jungleleaves", "default:jungleleaves")
minetest.register_alias("mapgen_apple", "default:apple")
minetest.register_alias("mapgen_water_source", "default:water_source")
minetest.register_alias("mapgen_river_water_source", "default:water_source")
minetest.register_alias("mapgen_dirt", "default:dirt")
minetest.register_alias("mapgen_sand", "default:sand")
minetest.register_alias("mapgen_gravel", "default:gravel")