Page 1 of 1

stoplight

Posted: Thu Sep 11, 2003 1:06 am
by smartaiguy
anyone know how to script a stoplight, like where you could set it up like a real-life stoplight? thanks! :D

EDIT: I should have been more specific the script turns the lights on and off.

easy

Posted: Thu Sep 11, 2003 9:26 am
by tltrude
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.

Posted: Thu Sep 11, 2003 10:43 am
by Bjarne BZR
Here is the code for lighting the colored brushes:

Code: Select all

$red_light light 1.0 0.0 0.0 300
$red_light lightOn
( use $red_light lightOff to turn it... off :), the first 3 numbers are the red, breen and blue components of the light)

Posted: Thu Sep 11, 2003 11:13 am
by Random
lighting the textures can be done through some nifty shader work too. A rotating texture with light emitting properties will also produce a nice stoplight with flashing lights and what not. Not sure if you can script it to turn on and off though.

Posted: Thu Sep 11, 2003 1:13 pm
by smartaiguy
I was planning on using low powered red ,green, and yellow lights

Posted: Thu Sep 11, 2003 6:51 pm
by 7th Es Cyborg
this should help, this is from my modified version of the light house level:

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
$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.

Image

Posted: Thu Sep 11, 2003 9:27 pm
by smartaiguy
ok thanks

Posted: Tue Sep 16, 2003 8:27 pm
by PsychoE
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?

Posted: Wed Sep 17, 2003 4:48 am
by Random
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?
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.


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

Image

Posted: Wed Sep 17, 2003 9:37 am
by Bjarne BZR
Looks nice. If you combine that with a dynamical colored ligt, it will look fabulous. :)

Posted: Wed Sep 17, 2003 1:24 pm
by PsychoE
I will give it a whirl as soon as i can. Thanks Random.

For Bjarne: is there somewhere I can read up on dynamical coloured lights?

Posted: Wed Sep 17, 2003 5:29 pm
by Bjarne BZR

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 lightOn
Need to know anything else: read the g_allclasses.html in the docs folder of radiant...

Posted: Wed Sep 17, 2003 7:29 pm
by PsychoE
I am quite dumb when it comes to scripting. :oops:

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!!

Posted: Wed Sep 17, 2003 7:41 pm
by Bjarne BZR
Just read the scripting tutorial a few times... and all will become clear ;)
http://www.planetmedalofhonor.com/rjuka ... guage.html