Scripting a light to change color

Post your scripting questions / solutions here

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

Post by SniperWolf »

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

Dynamic light

Post by tltrude »

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!
Tom Trude,

Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

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:

Code: Select all

$openinglight light 1 0 0 300 // red green blue radius
$openinglight light 0 1 0 300 // red green blue radius
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.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

script_models

Post by tltrude »

Need to get your eyes checked, Rookie One.pl. I said to use script_models! Script_origins will work too.
Tom Trude,

Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

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 .
Image
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Re: script_models

Post by Rookie One.pl »

tltrude wrote:Need to get your eyes checked, Rookie One.pl. I said to use script_models! Script_origins will work too.
Whoops! :oops: I stand corrected. Sorry!
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Ophisâ„¢
Colonel
Posts: 461
Joined: Sun Mar 12, 2006 2:30 pm
Location: England, Manchester
Contact:

Post by Ophisâ„¢ »

did i just see the perfect master at scripts rookie one get corrected?! Rookie? had a bad week? Whats wrong?
Image[ Formerly Known As Snakeâ„¢ ]
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

this thread needs to be stickied; if only because Rook failed at a lighting question :P
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

Lol. :P Yeah, I guess it was a bad day. :lol:

But it is indeed a good idea to sticky it. ;) For both reasons. :P
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post by SniperWolf »

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

Re: Dynamic light

Post by tltrude »

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!
Tom Trude,

Image
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post by SniperWolf »

Can I get the dyamic lights to react to the trigger i have set to iprint the text??

So when the nade pass throught the trigger it iprints some text & the lights switch from red to green??
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Yes, Have to set the spawnflags to 128 or somthing like that, Then have a setthread in the trigger, Or i think you can add the
Key/Value
key:message
value:hibbidy bibbidy
Image
SniperWolf
Colour Sergeant
Posts: 89
Joined: Sat Dec 18, 2004 5:14 am
Location: New York, USA
Contact:

Post by SniperWolf »

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.

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
        
         
Is this right or does it need a thread bottom_right_green to work???
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

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.
Image
Post Reply