Alright, here's a working version with triggers (same link as last time, I overwrote the file):
http://www.fortress-forever.com/publ...v_security.zip
Name the triggers: red_security_trigger and blue_security_trigger. You can also use either func_buttons or triggers with this Lua; they will both work.
Definitely re-download to get the new Lua, because I changed up the layout a bit to try to make it clear what should be edited and what shouldn't. Just FYI, though, here's what I added to make the triggers work:
Code:
SECURITY_LENGTH = 5
-- security triggers
base_security_trigger = team_only_trigger:new({ button = "" })
function base_security_trigger:ontrigger( player )
-- only take sec down if its up currently
local button = _G[self.button]
if button and button.sec_up then
self:onsecuritydown( player )
end
end
function base_security_trigger:onsecuritydown( player )
-- call the button's onin directly
local button = _G[self.button]
button.onin( button )
AddSchedule( self.button.."_security", SECURITY_LENGTH, function() self:onsecurityup() end )
end
function base_security_trigger:onsecurityup()
-- call the button's onout directly
local button = _G[self.button]
button.onout( button )
end
red_security_trigger = base_security_trigger:new( { team = Team.kRed, button = "button_red", allow=false } )
blue_security_trigger = base_security_trigger:new( { team = Team.kBlue, button = "button_blue", allow=false } )
It's somewhat complicated, but, basically, I'm re-using the button onin and onout functions from base_shutdown for the trigger being touched/security going back up. This makes it so that any changes to base_shutdown will not be overwritten (like if we add/change something on the HUD). Note: there do not need to be func_button entities in the map for this to work.