Scripting a light to change color
Moderator: Moderators
-
SniperWolf
- Colour Sergeant
- Posts: 89
- Joined: Sat Dec 18, 2004 5:14 am
- Location: New York, USA
- Contact:
Scripting a light to change color
Hey guys,
I'm making a training map for my clan. I have built a grenade range & have triggers in place so when u throw a nade into a opening it prints in text how many points you earned. I have also but a light entity in each opening & made it red.
So what i would like to happen is for the person to toss their nade into the opening & when the nade goes in the trigger will activate & will print the text & the red light will turn green.
I have the triggers for the text working already.
Can i make it change to green after the nade has been thrown into the opening??
Thanks in advance
SniperWolf
I'm making a training map for my clan. I have built a grenade range & have triggers in place so when u throw a nade into a opening it prints in text how many points you earned. I have also but a light entity in each opening & made it red.
So what i would like to happen is for the person to toss their nade into the opening & when the nade goes in the trigger will activate & will print the text & the red light will turn green.
I have the triggers for the text working already.
Can i make it change to green after the nade has been thrown into the opening??
Thanks in advance
SniperWolf
Dynamic light
Yes, but you'll have to use dynamic lights. Dynamic lights are like the light you see from muzzle flashes. It is done with script_models that have light properties set.
Key: light
Value: 300 <--default size of a point light
Key: _color
Value: 1 0 0 <--red
The three numbers are for red, green, and blue light (RGB). So, green would be Value: 0 1 0 .
Give the script_models targetnames. Then in your script you can use the commands "hide" and "show" to turn the lights off or on.
$red1 hide
$green1 show
The green lights will have to hidden in advance in the main thread of your script.
Hope that helps!
Key: light
Value: 300 <--default size of a point light
Key: _color
Value: 1 0 0 <--red
The three numbers are for red, green, and blue light (RGB). So, green would be Value: 0 1 0 .
Give the script_models targetnames. Then in your script you can use the commands "hide" and "show" to turn the lights off or on.
$red1 hide
$green1 show
The green lights will have to hidden in advance in the main thread of your script.
Hope that helps!
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
You can't do that with light entities, Tom. The light from them will get baked into the lightmap (the section of the BSP that contains light data) at light compile time, light entities are practically dummies from that point on.
But what you can do is use dynamic lights. Replace these lights that are supposed to change colours with script_origins and give them targetnames, and then use these script commands in appropriate places:
The first one will make it glow red, the other - green (the colour parameters are floating point numbers ranging from 0 to 1). I suggest you use the light entity's light value as the radius for similar results.
But what you can do is use dynamic lights. Replace these lights that are supposed to change colours with script_origins and give them targetnames, and then use these script commands in appropriate places:
Code: Select all
$openinglight light 1 0 0 300 // red green blue radius
$openinglight light 0 1 0 300 // red green blue radiusscript_models
Need to get your eyes checked, Rookie One.pl. I said to use script_models! Script_origins will work too.
It would work better with red and green coronas . Dynamic lights as well to light up objects near the light model but coronas that you show and hide definately would look better . I did a test map though of a traffic light that only used dynamic lights for the red yellow and green lights as well as pedestrian crossings it looked ok and used a lot of scriping for the lights . Here is the link to it if you want a look at it .
bdb_traffic_light.pk3
It includes the .map file and uses the fx/dummy.tik's as the light sources .
bdb_traffic_light.pk3
It includes the .map file and uses the fx/dummy.tik's as the light sources .
-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
Re: script_models
Whoops!tltrude wrote:Need to get your eyes checked, Rookie One.pl. I said to use script_models! Script_origins will work too.
did i just see the perfect master at scripts rookie one get corrected?! Rookie? had a bad week? Whats wrong?
[ Formerly Known As Snakeâ„¢ ]-
Rookie One.pl
- Site Admin
- Posts: 2752
- Joined: Fri Jan 31, 2003 7:49 pm
- Location: Nowa Wies Tworoska, Poland
- Contact:
-
SniperWolf
- Colour Sergeant
- Posts: 89
- Joined: Sat Dec 18, 2004 5:14 am
- Location: New York, USA
- Contact:
So I would map in the coronas then give them targetnames?? Then in the script use hide??
Is it possible to get an example script to see how it would look?
I never seen the hide command used be for.
Also, therw are 2 different coronas I can use. Which 1 sshould it be?
addon -> fx -> corona -> grren-bright or red-bright
OR
fx -> corona
Thanks Again Guys
Is it possible to get an example script to see how it would look?
I never seen the hide command used be for.
Also, therw are 2 different coronas I can use. Which 1 sshould it be?
addon -> fx -> corona -> grren-bright or red-bright
OR
fx -> corona
Thanks Again Guys
Re: Dynamic light
tltrude wrote:Yes, but you'll have to use dynamic lights. Dynamic lights are like the light you see from muzzle flashes. It is done with script_models that have light properties set.
Key: light
Value: 300 <--default size of a point light
Key: _color
Value: 1 0 0 <--red
The three numbers are for red, green, and blue light (RGB). So, green would be Value: 0 1 0 .
Give the script_models targetnames. Then in your script you can use the commands "hide" and "show" to turn the lights off or on.
$red1 hide
$green1 show
The green lights will have to hidden in advance in the main thread of your script.
Hope that helps!
-
SniperWolf
- Colour Sergeant
- Posts: 89
- Joined: Sat Dec 18, 2004 5:14 am
- Location: New York, USA
- Contact:
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
-
SniperWolf
- Colour Sergeant
- Posts: 89
- Joined: Sat Dec 18, 2004 5:14 am
- Location: New York, USA
- Contact:
OK, I decided to go with the addon -> fx -> corona -> green-bright & red-bright. I mapped them into my map & gave them the following targetnames:
bottom_right_red
bottom_right_green
this is what my script looks like to hide the green. And it doesnt work, I still see the coronas.
Is this right or does it need a thread bottom_right_green to work???
bottom_right_red
bottom_right_green
this is what my script looks like to hide the green. And it doesnt work, I still see the coronas.
Code: Select all
level.script = maps/dm/test.scr
level waittill spawn
$bottom_right_green hide
thread grenade_topleft_triggered <--- this thread works
grenade_topleft_triggered:
iprintin "Great Throw!! You Scored 5 Points.
end
-
Green Beret
- Major General
- Posts: 746
- Joined: Mon Apr 19, 2004 12:21 pm
- Contact:
Im not sure but add it to the thread maybe?
Code: Select all
level.script = maps/dm/test.scr
level waittill spawn
thread grenade_topleft_triggered <--- this thread works
grenade_topleft_triggered:
$bottom_right_green hide <----Try moving this here
iprintin "Great Throw!! You Scored 5 Points.
end
Last edited by Green Beret on Thu Aug 31, 2006 12:55 am, edited 1 time in total.




