Page 1 of 2

Scripting a light to change color

Posted: Fri Aug 25, 2006 2:49 am
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

Dynamic light

Posted: Fri Aug 25, 2006 5:47 am
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!

Posted: Fri Aug 25, 2006 8:30 am
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.

script_models

Posted: Fri Aug 25, 2006 11:31 am
by tltrude
Need to get your eyes checked, Rookie One.pl. I said to use script_models! Script_origins will work too.

Posted: Fri Aug 25, 2006 12:39 pm
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 .

Re: script_models

Posted: Fri Aug 25, 2006 3:52 pm
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!

Posted: Fri Aug 25, 2006 6:24 pm
by Ophisâ„¢
did i just see the perfect master at scripts rookie one get corrected?! Rookie? had a bad week? Whats wrong?

Posted: Fri Aug 25, 2006 7:12 pm
by lizardkid
this thread needs to be stickied; if only because Rook failed at a lighting question :P

Posted: Sat Aug 26, 2006 10:02 am
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

Posted: Sat Aug 26, 2006 11:11 am
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

Re: Dynamic light

Posted: Sun Aug 27, 2006 12:47 am
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!

Posted: Sun Aug 27, 2006 2:03 pm
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??

Posted: Sun Aug 27, 2006 3:24 pm
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

Posted: Tue Aug 29, 2006 1:50 pm
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???

Posted: Wed Aug 30, 2006 2:22 am
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