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 # Whether teams own the nodes around their flag
#ctf_node_ownership = true #ctf.node_ownership = true
#ctf_flag_protect_distance = 25 #ctf.flag_protect_distance = 25
# Can teams have multiple flags? # 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 # 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 # Are GUIs enabled
#ctf_gui = true #ctf.gui = true
# Is the HUD enabled # Is the HUD enabled
#ctf_hud = true #ctf.hud = true
# Team GUI on /team # Team GUI on /team
#ctf_team_gui = true #ctf.team_gui = true
# Default tab when opening Team GUI # Default tab when opening Team GUI
# news # news
# flags # flags
# diplo # diplo
# admin # admin
#ctf_team_gui_initial = news #ctf.team_gui_initial = news
# Enable tabs in Team GUI # Enable tabs in Team GUI
#ctf_flag_teleport_gui = true #ctf.flag_teleport_gui = true
#ctf_news_gui = true #ctf.news_gui = true
#ctf_diplomacy = true #ctf.diplomacy = true
# Show the spawn as a target in flag teleport Team GUI # 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? # Can flags have names?
#ctf_flag_names = true #ctf.flag_names = true
# Do teams have their own chat channel? # 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. # 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? # Can players change teams using /join?
#ctf_players_can_change_team",true) #ctf.players_can_change_team",true)
# How are players allocated to teams? # How are players allocated to teams?
# 0: none, # 0: none,
# 1: random, # 1: random,
# 2: one of first two largest groups, # 2: one of first two largest groups,
# 3 smallest group # 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 # 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) # The default Diplomacy state (if diplomacy is enabled)
# war # war
# peace # peace
# alliance # alliance
#ctf_default_diplo_state = war #ctf.default_diplo_state = war
# Chatplus distance - how far players can hear each other # 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) function ctf.register_on_save(func)
table.insert(ctf.registered_on_save, func) table.insert(ctf.registered_on_save, func)
end end
ctf.registered_on_init = {}
function ctf.register_on_init(func)
table.insert(ctf.registered_on_init, func)
end
function ctf.error(area, msg) function ctf.error(area, msg)
minetest.log("error", "CTF::" .. area .. " - " ..msg) minetest.log("error", "CTF::" .. area .. " - " ..msg)
@ -36,22 +40,24 @@ function ctf.init()
-- Settings: Feature enabling -- Settings: Feature enabling
ctf.log("init", "Creating Default Settings") ctf.log("init", "Creating Default Settings")
-- Settings: Flags and Territory
ctf._set("node_ownership", true) ctf._set("node_ownership", true)
ctf._set("multiple_flags", true) ctf._set("multiple_flags", true)
ctf._set("flag_capture_take", false) ctf._set("flag_capture_take", false)
ctf._set("flag_names", true)
-- Settings: User Interface
ctf._set("gui", true) ctf._set("gui", true)
ctf._set("hud", true) ctf._set("hud", true)
ctf._set("team_gui", true) ctf._set("team_gui", true)
ctf._set("flag_teleport_gui", true) ctf._set("flag_teleport_gui", true)
ctf._set("spawn_in_flag_teleport_gui", false) ctf._set("spawn_in_flag_teleport_gui", false)
ctf._set("news_gui", true) 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 -- Settings: Teams
ctf._set("diplomacy", true)
ctf._set("players_can_change_team", true)
ctf._set("allocate_mode", 0) ctf._set("allocate_mode", 0)
ctf._set("maximum_in_team", -1) ctf._set("maximum_in_team", -1)
ctf._set("default_diplo_state", "war") ctf._set("default_diplo_state", "war")
@ -60,6 +66,10 @@ function ctf.init()
ctf._set("flag_protect_distance", 25) ctf._set("flag_protect_distance", 25)
ctf._set("team_gui_initial", "news") ctf._set("team_gui_initial", "news")
for i = 1, #ctf.registered_on_init do
ctf.registered_on_init[i]()
end
ctf.load() ctf.load()
ctf.log("init", "Done!") ctf.log("init", "Done!")
@ -69,13 +79,18 @@ end
function ctf._set(setting, default) function ctf._set(setting, default)
ctf._defsettings[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.log("init", "- " .. setting .. ": " .. minetest.setting_get("ctf_"..setting))
ctf.warning("init", "deprecated setting ctf_"..setting..
" used, use ctf."..setting.." instead.")
end end
end end
function ctf.setting(name) 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] local dset = ctf._defsettings[name]
if set ~= nil then if set ~= nil then
if type(dset) == "number" then if type(dset) == "number" then

View File

@ -13,12 +13,13 @@ end)
function ctf.diplo.get(one,two) function ctf.diplo.get(one,two)
if not ctf.diplo.diplo then if not ctf.diplo.diplo then
return ctf.setting("default_diplo_state") return ctf.setting("default_diplo_state")
end end
for i=1,#ctf.diplo.diplo do for i = 1, #ctf.diplo.diplo do
local dip = ctf.diplo.diplo[i] 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 return dip.state
end end
end end
@ -26,24 +27,25 @@ function ctf.diplo.get(one,two)
return ctf.setting("default_diplo_state") return ctf.setting("default_diplo_state")
end end
function ctf.diplo.set(one,two,state) function ctf.diplo.set(one, two, state)
if not ctf.diplo.diplo then if ctf.diplo.diplo then
ctf.diplo.diplo = {} -- Check the table for an existing diplo state
else for i = 1, #ctf.diplo.diplo do
for i=1,#ctf.diplo.diplo do
local dip = ctf.diplo.diplo[i] 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 dip.state = state
return return
end end
end end
else
ctf.diplo.diplo = {}
end end
table.insert(ctf.diplo.diplo,{one=one,two=two,state=state}) table.insert(ctf.diplo.diplo,{one=one,two=two,state=state})
return
end end
function ctf.diplo.check_requests(one,two) function ctf.diplo.check_requests(one, two)
local team = ctf.team(two) local team = ctf.team(two)
if not team.log then if not team.log then
@ -51,7 +53,9 @@ function ctf.diplo.check_requests(one,two)
end end
for i=1,#team.log do 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 return team.log[i].msg
end end
end end
@ -59,7 +63,7 @@ function ctf.diplo.check_requests(one,two)
return nil return nil
end end
function ctf.diplo.cancel_requests(one,two) function ctf.diplo.cancel_requests(one, two)
local team = ctf.team(two) local team = ctf.team(two)
if not team.log then if not team.log then
@ -67,7 +71,9 @@ function ctf.diplo.cancel_requests(one,two)
end end
for i=1,#team.log do 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) table.remove(team.log,i)
return return
end 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) local function team_console_help(name)
minetest.chat_send_player(name,"Try:", false) minetest.chat_send_player(name,"Try:", false)
minetest.chat_send_player(name,"/team - show team panel", false) minetest.chat_send_player(name,"/team - show team panel", false)

View File

@ -1,139 +1,146 @@
ARROW_DAMAGE = 2 function init()
ARROW_VELOCITY = 2 ctf._set("turrets", true)
minetest.register_node("ctf_turret:turret", { end
description = "Team Turret", init()
tiles = {
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
},
drawtype="nodebox",
groups={attached_node=1},
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.000000,0.500000}, --NodeBox 1
{-0.437500,0.000000,-0.437500,0.431250,0.187500,0.431250}, --NodeBox 2
{-0.187500,0.187500,-0.187500,0.187500,0.500000,0.187500}, --NodeBox 3
}
},
groups = {cracky=3, stone=1},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Unowned turret")
end,
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
if meta and ctf.players and ctf.player(placer:get_player_name()) and ctf.player(placer:get_player_name()).team then if ctf.setting("turrets") then
local team = ctf.player(placer:get_player_name()).team ARROW_DAMAGE = 2
meta:set_string("team", team) ARROW_VELOCITY = 2
meta:set_string("infotext", "Owned by "..team) minetest.register_node("ctf_turret:turret", {
else description = "Team Turret",
minetest.env:set_node(pos,{name="air"}) tiles = {
end "default_stone.png",
end "default_stone.png",
}) "default_stone.png",
"default_stone.png",
"default_stone.png",
"default_stone.png",
},
drawtype="nodebox",
groups={attached_node=1},
paramtype = "light",
node_box = {
type = "fixed",
fixed = {
{-0.500000,-0.500000,-0.500000,0.500000,0.000000,0.500000}, --NodeBox 1
{-0.437500,0.000000,-0.437500,0.431250,0.187500,0.431250}, --NodeBox 2
{-0.187500,0.187500,-0.187500,0.187500,0.500000,0.187500}, --NodeBox 3
}
},
groups = {cracky=3, stone=1},
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_string("infotext", "Unowned turret")
end,
after_place_node = function(pos, placer)
local meta = minetest.env:get_meta(pos)
minetest.register_abm({ if meta and ctf.players and ctf.player(placer:get_player_name()) and ctf.player(placer:get_player_name()).team then
nodenames = {"ctf_turret:turret"}, local team = ctf.player(placer:get_player_name()).team
interval = 0.25, meta:set_string("team", team)
chance = 4, meta:set_string("infotext", "Owned by "..team)
action = function(pos, node) else
local meta = minetest.env:get_meta(pos) minetest.env:set_node(pos,{name="air"})
if not meta then
return
end
local team = meta:get_string("team")
if not team then
return
end
local app = ctf.area.get_area(pos)
if app and app~=team then
team = app
meta:set_string("team",team)
meta:set_string("infotext", "Owned by "..team)
end
if not team then
return
end
local objects = minetest.env:get_objects_inside_radius(pos, 15)
for _,obj in ipairs(objects) do
if (
obj:is_player() and
ctf.players and
ctf.player(obj:get_player_name()) and
ctf.player(obj:get_player_name()).team ~= team
)then
-- Calculate stuff
local obj_p = obj:getpos()
local calc = {
x=obj_p.x - pos.x,
y=obj_p.y+1 - pos.y,
z=obj_p.z - pos.z
}
-- Create bullet entity
local bullet=minetest.env:add_entity({x=pos.x,y=pos.y+0.5,z=pos.z}, "ctf_turret:arrow_entity")
-- Set velocity
bullet:setvelocity({x=calc.x * ARROW_VELOCITY,y=calc.y * ARROW_VELOCITY,z=calc.z * ARROW_VELOCITY})
-- Play sound
minetest.sound_play("laser", {pos = pos, gain = 1.0, max_hear_distance = 50,})
end end
end end
end })
})
-- The Arrow Entity minetest.register_abm({
THROWING_ARROW_ENTITY={ nodenames = {"ctf_turret:turret"},
physical = false, interval = 0.25,
timer=0, chance = 4,
visual_size = {x=0.2, y=0.2}, action = function(pos, node)
textures = {"bullet.png"}, local meta = minetest.env:get_meta(pos)
lastpos={}, if not meta then
collisionbox = {-0.17,-0.17,-0.17,0.17,0.17,0.17}, return
on_step = function(self, dtime) end
self.timer=self.timer+dtime
local pos = self.object:getpos()
if self.timer > 2 then
self.object:remove()
end
if self.timer > 0.2 then local team = meta:get_string("team")
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5) if not team then
for k, obj in pairs(objs) do return
if obj:is_player() then end
obj:set_hp(obj:get_hp() - ARROW_DAMAGE)
self.object:remove() local app = ctf.area.get_area(pos)
if app and app~=team then
team = app
meta:set_string("team",team)
meta:set_string("infotext", "Owned by "..team)
end
if not team then
return
end
local objects = minetest.env:get_objects_inside_radius(pos, 15)
for _,obj in ipairs(objects) do
if (
obj:is_player() and
ctf.players and
ctf.player(obj:get_player_name()) and
ctf.player(obj:get_player_name()).team ~= team
)then
-- Calculate stuff
local obj_p = obj:getpos()
local calc = {
x=obj_p.x - pos.x,
y=obj_p.y+1 - pos.y,
z=obj_p.z - pos.z
}
-- Create bullet entity
local bullet=minetest.env:add_entity({x=pos.x,y=pos.y+0.5,z=pos.z}, "ctf_turret:arrow_entity")
-- Set velocity
bullet:setvelocity({x=calc.x * ARROW_VELOCITY,y=calc.y * ARROW_VELOCITY,z=calc.z * ARROW_VELOCITY})
-- Play sound
minetest.sound_play("laser", {pos = pos, gain = 1.0, max_hear_distance = 50,})
end end
end end
end end
})
local node = minetest.env:get_node(pos) -- The Arrow Entity
if node.name ~= "air" and node.name ~= "ctf_turret:turret" then THROWING_ARROW_ENTITY={
--minetest.env:add_item(self.lastpos, "throwing:arrow") physical = false,
self.object:remove() timer=0,
visual_size = {x=0.2, y=0.2},
textures = {"bullet.png"},
lastpos={},
collisionbox = {-0.17,-0.17,-0.17,0.17,0.17,0.17},
on_step = function(self, dtime)
self.timer=self.timer+dtime
local pos = self.object:getpos()
if self.timer > 2 then
self.object:remove()
end
if self.timer > 0.2 then
local objs = minetest.env:get_objects_inside_radius({x=pos.x,y=pos.y,z=pos.z}, 1.5)
for k, obj in pairs(objs) do
if obj:is_player() then
obj:set_hp(obj:get_hp() - ARROW_DAMAGE)
self.object:remove()
end
end
end
local node = minetest.env:get_node(pos)
if node.name ~= "air" and node.name ~= "ctf_turret:turret" then
--minetest.env:add_item(self.lastpos, "throwing:arrow")
self.object:remove()
end
end end
end
}
minetest.register_entity("ctf_turret:arrow_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = "ctf_turret:turret",
recipe = {
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"},
{"default:gold_ingot", "default:mese_crystal", "default:gold_ingot"},
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"}
} }
})
minetest.register_entity("ctf_turret:arrow_entity", THROWING_ARROW_ENTITY)
minetest.register_craft({
output = "ctf_turret:turret",
recipe = {
{"default:mese_crystal", "default:gold_ingot", "default:mese_crystal"},
{"default:gold_ingot", "default:mese_crystal", "default:gold_ingot"},
{"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_jungleleaves", "default:jungleleaves")
minetest.register_alias("mapgen_apple", "default:apple") minetest.register_alias("mapgen_apple", "default:apple")
minetest.register_alias("mapgen_water_source", "default:water_source") 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_dirt", "default:dirt")
minetest.register_alias("mapgen_sand", "default:sand") minetest.register_alias("mapgen_sand", "default:sand")
minetest.register_alias("mapgen_gravel", "default:gravel") minetest.register_alias("mapgen_gravel", "default:gravel")