mirror of
https://github.com/fortressforever/fortressforever-scripts.git
synced 2025-05-31 00:30:51 +00:00
Review: Avoid the ternary operator and remove redundant safety when saving base security_* functions
This commit is contained in:
parent
3c7a7e7426
commit
8bf25793c4
5 changed files with 42 additions and 18 deletions
|
@ -154,12 +154,18 @@ red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
|
|||
red_aardvarksec = red_security_trigger:new()
|
||||
blue_aardvarksec = blue_security_trigger:new()
|
||||
|
||||
local security_off_base = security_off or function() end
|
||||
-- utility function for getting the name of the opposite team,
|
||||
-- where team is a string, like "red"
|
||||
local function get_opposite_team(team)
|
||||
if team == "red" then return "blue" else return "red" end
|
||||
end
|
||||
|
||||
local security_off_base = security_off
|
||||
function security_off( team )
|
||||
security_off_base( team )
|
||||
|
||||
OpenDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
|
||||
|
||||
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
|
||||
|
@ -167,12 +173,12 @@ function security_off( team )
|
|||
end)
|
||||
end
|
||||
|
||||
local security_on_base = security_on or function() end
|
||||
local security_on_base = security_on
|
||||
function security_on( team )
|
||||
security_on_base( team )
|
||||
|
||||
CloseDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
|
||||
end
|
||||
|
||||
|
|
|
@ -65,12 +65,18 @@ red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
|
|||
red_aardvarksec = red_security_trigger:new()
|
||||
blue_aardvarksec = blue_security_trigger:new()
|
||||
|
||||
local security_off_base = security_off or function() end
|
||||
-- utility function for getting the name of the opposite team,
|
||||
-- where team is a string, like "red"
|
||||
local function get_opposite_team(team)
|
||||
if team == "red" then return "blue" else return "red" end
|
||||
end
|
||||
|
||||
local security_off_base = security_off
|
||||
function security_off( team )
|
||||
security_off_base( team )
|
||||
|
||||
OpenDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
|
||||
|
||||
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
|
||||
|
@ -78,12 +84,12 @@ function security_off( team )
|
|||
end)
|
||||
end
|
||||
|
||||
local security_on_base = security_on or function() end
|
||||
local security_on_base = security_on
|
||||
function security_on( team )
|
||||
security_on_base( team )
|
||||
|
||||
CloseDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
|
||||
end
|
||||
|
||||
|
|
|
@ -61,12 +61,18 @@ red_aardvarkresup = aardvarkresup:new({ team = Team.kRed })
|
|||
red_aardvarksec = red_security_trigger:new()
|
||||
blue_aardvarksec = blue_security_trigger:new()
|
||||
|
||||
local security_off_base = security_off or function() end
|
||||
-- utility function for getting the name of the opposite team,
|
||||
-- where team is a string, like "red"
|
||||
local function get_opposite_team(team)
|
||||
if team == "red" then return "blue" else return "red" end
|
||||
end
|
||||
|
||||
local security_off_base = security_off
|
||||
function security_off( team )
|
||||
security_off_base( team )
|
||||
|
||||
OpenDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
|
||||
|
||||
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
|
||||
|
@ -74,12 +80,12 @@ function security_off( team )
|
|||
end)
|
||||
end
|
||||
|
||||
local security_on_base = security_on or function() end
|
||||
local security_on_base = security_on
|
||||
function security_on( team )
|
||||
security_on_base( team )
|
||||
|
||||
CloseDoor(team.."_aardvarkdoorhack")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
|
||||
end
|
||||
|
||||
|
|
|
@ -127,12 +127,18 @@ blue_dspawn = { validspawn = blue_d_only }
|
|||
red_sec = red_security_trigger:new()
|
||||
blue_sec = blue_security_trigger:new()
|
||||
|
||||
local security_off_base = security_off or function() end
|
||||
-- utility function for getting the name of the opposite team,
|
||||
-- where team is a string, like "red"
|
||||
local function get_opposite_team(team)
|
||||
if team == "red" then return "blue" else return "red" end
|
||||
end
|
||||
|
||||
local security_off_base = security_off
|
||||
function security_off( team )
|
||||
security_off_base( team )
|
||||
|
||||
OpenDoor(team.."_secdoor")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Disable")
|
||||
|
||||
AddSchedule("secup10"..team, SECURITY_LENGTH - 10, function()
|
||||
|
@ -143,12 +149,12 @@ function security_off( team )
|
|||
end)
|
||||
end
|
||||
|
||||
local security_on_base = security_on or function() end
|
||||
local security_on_base = security_on
|
||||
function security_on( team )
|
||||
security_on_base( team )
|
||||
|
||||
CloseDoor(team.."_secdoor")
|
||||
local opposite_team = team == "red" and "blue" or "red"
|
||||
local opposite_team = get_opposite_team(team)
|
||||
OutputEvent("sec_"..opposite_team.."_slayer", "Enable")
|
||||
end
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ SECURITY_LENGTH = 60
|
|||
red_aardvarksec = red_security_trigger:new()
|
||||
blue_aardvarksec = blue_security_trigger:new()
|
||||
|
||||
local security_off_base = security_off or function() end
|
||||
local security_off_base = security_off
|
||||
function security_off( team )
|
||||
security_off_base( team )
|
||||
|
||||
|
@ -24,7 +24,7 @@ function security_off( team )
|
|||
end)
|
||||
end
|
||||
|
||||
local security_on_base = security_on or function() end
|
||||
local security_on_base = security_on
|
||||
function security_on( team )
|
||||
security_on_base( team )
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue