stoplight

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
smartaiguy
Brigadier General
Posts: 512
Joined: Tue Jul 08, 2003 2:52 pm

stoplight

Post 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.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

easy

Post 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.
Tom Trude,

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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)
Admin .MAP Forums
Image
Head above heels.
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post 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.
Moderator
Image
smartaiguy
Brigadier General
Posts: 512
Joined: Tue Jul 08, 2003 2:52 pm

Post by smartaiguy »

I was planning on using low powered red ,green, and yellow lights
7th Es Cyborg
First Lieutenant
Posts: 189
Joined: Fri Dec 13, 2002 5:00 pm
Location: PA
Contact:

Post 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
smartaiguy
Brigadier General
Posts: 512
Joined: Tue Jul 08, 2003 2:52 pm

Post by smartaiguy »

ok thanks
User avatar
PsychoE
Captain
Posts: 243
Joined: Mon Oct 21, 2002 7:40 pm

Post 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?
PSYCHO - Who you callin a PSYCHO?

Image
Random
Moderator
Posts: 401
Joined: Sun Jun 01, 2003 11:00 pm

Post 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
Moderator
Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Looks nice. If you combine that with a dynamical colored ligt, it will look fabulous. :)
Admin .MAP Forums
Image
Head above heels.
User avatar
PsychoE
Captain
Posts: 243
Joined: Mon Oct 21, 2002 7:40 pm

Post 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?
PSYCHO - Who you callin a PSYCHO?

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post 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...
Admin .MAP Forums
Image
Head above heels.
User avatar
PsychoE
Captain
Posts: 243
Joined: Mon Oct 21, 2002 7:40 pm

Post 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!!
PSYCHO - Who you callin a PSYCHO?

Image
Bjarne BZR
Site Admin
Posts: 3298
Joined: Wed Feb 05, 2003 2:04 pm
Location: Sweden
Contact:

Post by Bjarne BZR »

Just read the scripting tutorial a few times... and all will become clear ;)
http://www.planetmedalofhonor.com/rjuka ... guage.html
Admin .MAP Forums
Image
Head above heels.
Post Reply