03-08-2008, 06:42 PM | #1 |
Join Date: May 2007
Posts Rated Helpful 0 Times
|
How does a Capture Flag trigger Outputs?
I'm trying to make a map where Capping will result in doors opening and closing. Can someone help? I tried using the output on the trigger_ff_script cap point with no results.
|
|
03-10-2008, 01:43 AM | #2 |
Lua Team
Join Date: Mar 2007
Posts Rated Helpful 1 Times
|
You need to override the function basecap : oncapture(player, item)
Code:
my_cap = basecap:new({}) function my_cap:oncapture(player, item) if player:GetTeamId() == Team.kBlue then -- open doors and stuff for blue capture here elseif player:GetTeamId() == Team.kRed then -- opend doors and stuff for Red capture here end -- let the teams know that a capture occured SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap") SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP") SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP") end red_my_cap = my_cap:new({team = Team.kRed, item = {"blue_flag","yellow_flag","green_flag"}}) blue_my_cap = my_cap:new({team = Team.kBlue, item = {"red_flag","yellow_flag","green_flag"}}) Hope this helps. The above code is totally untested, as usual. |
|
03-10-2008, 03:53 PM | #3 |
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
Sidd has it right
|
|
03-10-2008, 08:09 PM | #4 |
Join Date: May 2007
Posts Rated Helpful 0 Times
|
I'm going need a little more help. I renamed my 4 colored caps "blue_my_cap"...etc. And first I tried to see if the outputs on the caps would respond without any altercations to the LUA but I knew my luck wouldn't be that good. Next I tried to alter the code so it'd activate a logic_relay which would then Output what I needed... that didn't work either. So now I guess I want to have the LUA trigger all the doors, but I'm not sure how to add multiple outputs in an LUA. So please help me clean up my LUA based on your original.
Code:
my_cap = basecap:new({}) function my_cap:oncapture(player, item) if player:GetTeamId() == Team.kBlue then -- OutputEvent( alpha_door1, "Open" ) -- OutputEvent( alpha_door2, "Open" ) -- OutputEvent( alpha_door3, "Open" ) -- OutputEvent( alpha_door4, "Open" ) -- OutputEvent( alpha_maingate, "Open" ) -- OutputEvent( alphaspecialdoor, "Disable" ) -- OutputEvent( beta_door1, "Close" ) -- OutputEvent( beta_door2, "Close" ) -- OutputEvent( beta_door3, "Close" ) -- OutputEvent( beta_door4, "Close" ) -- OutputEvent( beta_maingate, "Close" ) -- OutputEvent( betaspecialdoor, "Enable" ) elseif player:GetTeamId() == Team.kGreen then -- OutputEvent( alpha_door1, "Open" ) -- OutputEvent( alpha_door2, "Open" ) -- OutputEvent( alpha_door3, "Open" ) -- OutputEvent( alpha_door4, "Open" ) -- OutputEvent( alpha_maingate, "Open" ) -- OutputEvent( alphaspecialdoor, "Disable" ) -- OutputEvent( beta_door1, "Close" ) -- OutputEvent( beta_door2, "Close" ) -- OutputEvent( beta_door3, "Close" ) -- OutputEvent( beta_door4, "Close" ) -- OutputEvent( beta_maingate, "Close" ) -- OutputEvent( betaspecialdoor, "Enable" ) elseif player:GetTeamId() == Team.kYellow then -- OutputEvent( alpha_door1, "Close" ) -- OutputEvent( alpha_door2, "Close" ) -- OutputEvent( alpha_door3, "Close" ) -- OutputEvent( alpha_door4, "Close" ) -- OutputEvent( alpha_maingate, "Close" ) -- OutputEvent( alphaspecialdoor, "Enable" ) -- OutputEvent( beta_door1, "Open" ) -- OutputEvent( beta_door2, "Open" ) -- OutputEvent( beta_door3, "Open" ) -- OutputEvent( beta_door4, "Open" ) -- OutputEvent( beta_maingate, "Open" ) -- OutputEvent( betaspecialdoor, "Disable" ) elseif player:GetTeamId() == Team.kRed then -- OutputEvent( alpha_door1, "Close" ) -- OutputEvent( alpha_door2, "Close" ) -- OutputEvent( alpha_door3, "Close" ) -- OutputEvent( alpha_door4, "Close" ) -- OutputEvent( alpha_maingate, "Close" ) -- OutputEvent( alphaspecialdoor, "Enable" ) -- OutputEvent( beta_door1, "Open" ) -- OutputEvent( beta_door2, "Open" ) -- OutputEvent( beta_door3, "Open" ) -- OutputEvent( beta_door4, "Open" ) -- OutputEvent( beta_maingate, "Open" ) -- OutputEvent( betaspecialdoor, "Disable" ) end -- let the teams know that a capture occured SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap") SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP") SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP") end blue_my_cap = my_cap:new({team = Team.kBlue, item = {"green_flag"}}) red_my_cap = my_cap:new({team = Team.kRed, item = {"yellow_flag"}}) yellow_my_cap = my_cap:new({team = Team.kYellow, item = {"red_flag"}}) green_my_cap = my_cap:new({team = Team.kGreen, item = {"blue_flag"}}) |
|
03-10-2008, 08:51 PM | #5 |
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
i am pretty sure you need quotes around the first parameter of outputevent
OutputEvent( "betaspecialdoor", "Disable" ) not OutputEvent( betaspecialdoor, "Disable" ) |
|
03-10-2008, 09:34 PM | #6 |
Lua Team
Join Date: Mar 2007
Posts Rated Helpful 1 Times
|
Code:
function open_the_doors() OutputEvent( "alpha_door1", "Open" ) OutputEvent( "alpha_door2", "Open" ) OutputEvent( "alpha_door3", "Open" ) OutputEvent( "alpha_door4", "Open" ) OutputEvent( "alpha_maingate", "Open" ) OutputEvent( "alphaspecialdoor", "Disable" ) OutputEvent( "beta_door1", "Close" ) OutputEvent( "beta_door2", "Close" ) OutputEvent( "beta_door3", "Close" ) OutputEvent( "beta_door4", "Close" ) OutputEvent( "beta_maingate", "Close" ) OutputEvent( "betaspecialdoor", "Enable" ) end my_cap = basecap:new({}) function my_cap:oncapture(player, item) if player:GetTeamId() == Team.kBlue then open_the_doors() elseif player:GetTeamId() == Team.kGreen then open_the_doors() elseif player:GetTeamId() == Team.kYellow then open_the_doors() elseif player:GetTeamId() == Team.kRed then open_the_doors() end -- let the teams know that a capture occured SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap") SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP") SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP") end blue_my_cap = my_cap:new({team = Team.kBlue, item = {"green_flag"}}) -- This only lets blue capture the green flag -- perhaps instead you want : -- item = {"blue_flag","yellow_flag","green_flag"}}) red_my_cap = my_cap:new({team = Team.kRed, item = {"yellow_flag"}}) yellow_my_cap = my_cap:new({team = Team.kYellow, item = {"red_flag"}}) green_my_cap = my_cap:new({team = Team.kGreen, item = {"blue_flag"}}) |
|
03-10-2008, 09:35 PM | #7 |
Join Date: May 2007
Posts Rated Helpful 0 Times
|
OMG I think it works!
Thanks so much for the help. I'm really happy cause I think the LUA is perfect now. I just need to work on texturing the map and stuff but I might be able to post pics soon. Thanks again! |
|
03-10-2008, 09:48 PM | #8 |
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
I dont think it works right. Sidd, you would need a second function because your current one doesn't cover all the output events he listed in his 2nd post. Plus, after the first capture, it isnt really doing anything to the doors.
|
|
03-10-2008, 09:57 PM | #9 |
Join Date: Sep 2007
Posts Rated Helpful 0 Times
|
Code:
function open_the_doors() OutputEvent( "alpha_door1", "Open" ) OutputEvent( "alpha_door2", "Open" ) OutputEvent( "alpha_door3", "Open" ) OutputEvent( "alpha_door4", "Open" ) OutputEvent( "alpha_maingate", "Open" ) OutputEvent( "alphaspecialdoor", "Disable" ) OutputEvent( "beta_door1", "Close" ) OutputEvent( "beta_door2", "Close" ) OutputEvent( "beta_door3", "Close" ) OutputEvent( "beta_door4", "Close" ) OutputEvent( "beta_maingate", "Close" ) OutputEvent( "betaspecialdoor", "Enable" ) end function open_the_doors2() OutputEvent( "alpha_door1", "Close" ) OutputEvent( "alpha_door2", "Close" ) OutputEvent( "alpha_door3", "Close" ) OutputEvent( "alpha_door4", "Close" ) OutputEvent( "alpha_maingate", "Close" ) OutputEvent( "alphaspecialdoor", "Enable" ) OutputEvent( "beta_door1", "Open" ) OutputEvent( "beta_door2", "Open" ) OutputEvent( "beta_door3", "Open" ) OutputEvent( "beta_door4", "Open" ) OutputEvent( "beta_maingate", "Open" ) OutputEvent( "betaspecialdoor", "Disable" ) end my_cap = basecap:new({}) function my_cap:oncapture(player, item) if player:GetTeamId() == Team.kBlue then open_the_doors() elseif player:GetTeamId() == Team.kGreen then open_the_doors() elseif player:GetTeamId() == Team.kYellow then open_the_doors2() elseif player:GetTeamId() == Team.kRed then open_the_doors2() end -- let the teams know that a capture occured SmartSound(player, "yourteam.flagcap", "yourteam.flagcap", "otherteam.flagcap") SmartSpeak(player, "CTF_YOUCAP", "CTF_TEAMCAP", "CTF_THEYCAP") SmartMessage(player, "#FF_YOUCAP", "#FF_TEAMCAP", "#FF_OTHERTEAMCAP") end blue_my_cap = my_cap:new({team = Team.kBlue, item = {"green_flag"}}) -- This only lets blue capture the green flag -- perhaps instead you want : -- item = {"blue_flag","yellow_flag","green_flag"}}) red_my_cap = my_cap:new({team = Team.kRed, item = {"yellow_flag"}}) yellow_my_cap = my_cap:new({team = Team.kYellow, item = {"red_flag"}}) green_my_cap = my_cap:new({team = Team.kGreen, item = {"blue_flag"}}) |
|
03-10-2008, 10:12 PM | #10 |
Lua Team
Join Date: Mar 2007
Posts Rated Helpful 1 Times
|
yeah, I didn't realise he wanted 2 different things doing depending on who captures.
Which is one example why you should use small functions to group even a few lines of code. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|