EDIT: I should have been more specific the script turns the lights on and off.
stoplight
Moderator: Moderators
-
smartaiguy
- Brigadier General
- Posts: 512
- Joined: Tue Jul 08, 2003 2:52 pm
stoplight
anyone know how to script a stoplight, like where you could set it up like a real-life stoplight? thanks! 
EDIT: I should have been more specific the script turns the lights on and off.
EDIT: I should have been more specific the script turns the lights on and off.
easy
It would be easy to use script_object colored brushes and "hide" and "show" them in the script. But, if you want it to really cast light, it will be a bit harder. You would have to use "dynamic" lights--same lights used for muzzle flashes.
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
Here is the code for lighting the colored brushes:
( use $red_light lightOff to turn it... off
, the first 3 numbers are the red, breen and blue components of the light)
Code: Select all
$red_light light 1.0 0.0 0.0 300
$red_light lightOn-
smartaiguy
- Brigadier General
- Posts: 512
- Joined: Tue Jul 08, 2003 2:52 pm
-
7th Es Cyborg
- First Lieutenant
- Posts: 189
- Joined: Fri Dec 13, 2002 5:00 pm
- Location: PA
- Contact:
this should help, this is from my modified version of the light house level:
$beam is the brush shown below ( which I think is textured with one of the gradiants in the common folder )
$lamp is just a script object in the center of the lighthouse to make everything rotate.
While the lights stay on all the time - you can only see the beams when the script shows them - it should work for your stoplight if you do something similar and turn the beams on and off in a sequence.

Code: Select all
lighthouseprep:
$beam hide
$beam bind $lamp
level.lighton = 0
thread lighthouseswitch
end
lighthouseswitch:
$lighthouse waittill trigger
local.player = parm.other
if ((level.lighton == 0) && (local.player.dmteam != "axis"))
{
$switchnopulse anim move
$beam show
$lamp rotatey 15
$lamp loopsound lighthouse_run
level.lighton = 1
wait .1
iprintlnbold "Allies have turned on the Lighthouse beam !!"
$axis2 enablespawn
$allied2 enablespawn
$axis1 disablespawn
$allied1 disablespawn
}
else
{
if ((level.lighton == 1) && (local.player.dmteam != "allies"))
{
$switchnopulse anim idle
$beam hide
$lamp rotatey 0
$lamp stoploopsound
level.lighton = 0
wait .1
iprintlnbold "Axis have turned off the beam !!"
$axis1 enablespawn
$allied1 enablespawn
$axis2 disablespawn
$allied2 disablespawn
}
else
{
wait .1
}
}
wait .5
goto lighthouseswitch
end
$lamp is just a script object in the center of the lighthouse to make everything rotate.
While the lights stay on all the time - you can only see the beams when the script shows them - it should work for your stoplight if you do something similar and turn the beams on and off in a sequence.

Realistic stop lights could easily be made through shader work i will create an example or at least try to and be back in a minute.PsychoE wrote:Hello (Im back)
Goodness, is there an easier way to do this? I would like to try and put stoplights in a map, but don't know if i can handle this. What if i said i wanted just a flashing amber or red?
Well it took more than a minute for some dam reason i was having troubles with loading the custom texture into radiant.....hm go fig? Then i was missing on the timing between the different lights. You know makin sure that while one was red the other was green and the amount of time needed to wait for the yellow to turn red and have the other face turn green at the right time. We dont want any accidents now do we. But hour or so later i got it. I threw together a demonstration of what i was refering to with the shaders. Much easier than scripting an entire network of street lights. Hope some of you can make use of this.
Stoplight Demo

Moderator


-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
Code: Select all
local.an_origin = spawn script_origin
local.an_origin = ( 100.0 100.0 100.0 )
// 1:st number: red component ( from 0 to 1 )
// 2:nd number: green component ( from 0 to 1 )
// 3:rd number: blue component ( from 0 to 1 )
// 4:th number: light radius
local.an_origin light 1.0 0.0 0.0 300
local.an_origin lightOnI am quite dumb when it comes to scripting.
I scanned through the g_allclasses as well and it makes no sense to me. I wouldn't know how or where to use any of this stuff. I rely heavily on scritping tuts and even then, i can only mod them very basically to my own maps requirements.
Im sure that code makes sense to a lot of ppl, but not to me. Thanks for the reply tho Bjarne!!
I scanned through the g_allclasses as well and it makes no sense to me. I wouldn't know how or where to use any of this stuff. I rely heavily on scritping tuts and even then, i can only mod them very basically to my own maps requirements.
Im sure that code makes sense to a lot of ppl, but not to me. Thanks for the reply tho Bjarne!!
PSYCHO - Who you callin a PSYCHO?


-
Bjarne BZR
- Site Admin
- Posts: 3298
- Joined: Wed Feb 05, 2003 2:04 pm
- Location: Sweden
- Contact:
Just read the scripting tutorial a few times... and all will become clear 
http://www.planetmedalofhonor.com/rjuka ... guage.html
http://www.planetmedalofhonor.com/rjuka ... guage.html

