spawning a light entity?

Post your scripting questions / solutions here

Moderator: Moderators

Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

spawning a light entity?

Post by Master-Of-Fungus-Foo-D »

How would you script-spawn a light. Not a static light model but the actual LIGHT. Could someone help me a little?
._
/..\
\_/
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post by Angex »

I don't think you can spawn a light it terms of a light enttiy, as the lighting is calculated at compile time.

You can however assign a dynamic light to an entity, this is how muzzel flashes are done for example, but you may notice an impact on performance if you over use it.

So you could spawn a script_origin or script_model and use the light( Float red, Float green, Float blue, Float radius )
, I think the rgb variables are within the range of 0 - 1.

E.G.

Code: Select all

// Spawn some kind of entity.
$my_entity light 0 0.5 1 128
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

what do you mean by
You can however assign a dynamic light to an entity, this is how muzzel flashes are done for example, but you may notice an impact on performance if you over use it.
and
Float red, Float green, Float blue, Float radius
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

red value of light, blue value of light, green value of light, each is applied to the entity. float means floating-point, or decimal. these values are applied jsut like ambinetlight or farplane_color but to the entity.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

spawn a Dynamic light

Post by tltrude »

This may help. It should spawn a bright light just above the very center of the map.

mylite_thread:
local.lite = spawn script_model model "fx/dummy.tik"
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
end
Last edited by tltrude on Thu Aug 12, 2004 5:39 am, edited 1 time in total.
Tom Trude,

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

Post by bdbodger »

The light can also be turned on and off if you do a light this way

mylite_thread:
local.lite = spawn script_model model "fx_dummy.tik" targetname mylight
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
thread blink_light
end

blink_light:

while(1)
{
$mylight lighton
wait 3
$mylight lightoff
wait 3
}
end
Image
nuggets
General
Posts: 1006
Joined: Fri Feb 28, 2003 2:57 am
Location: U-england-K (england in the UK) :P
Contact:

Post by nuggets »

or you can make it fade in and out by using

mylite_thread:
local.lite = spawn script_model model "fx_dummy.tik" targetname mylight
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 0 // last number is how big it is, ( 1 1 1 is white light).
local.lite.strength = 0
thread brighten local.lite
end

brighten local.lite:
while (1)
{
if (local.lite.strength <=300)
{
local.lite light 1 1 1 local.strength
local.strength = (local.strength + 2)
wait .02
}
else
{
thread dim local.lite
break
}
}
end

dim local.lite:
while (1)
{
if (local.lite.strength = 0)
{
local.lite light 1 1 1 local.strength
local.strength = (local.strength - 2)
wait .02
}
else
{
thread brighten local.lite
break
}
}
end

also a thing to note:
these dynamic lights aren't affected by walls, they'll shine on the other side of them, so be careful where you place them
hope this helps, prob not cos it's all foreign 2 me :-/
Master-Of-Fungus-Foo-D
Muffin Man
Posts: 1544
Joined: Tue Jan 27, 2004 12:33 am
Location: cali, United States

Post by Master-Of-Fungus-Foo-D »

cool. I should try these techniques.(man thats hard to spell)
Image
The Fungus Theme song!!!

Code: Select all

while (local.player istouching self)
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

hey, a bit late reply .. but i need help..

Code: Select all

// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm2"

	// call additional stuff for playing this map round based is needed
	if(level.roundbased)
		thread roundbasedthread

	level waittill prespawn

	//*** Precache Dm Stuff
	exec global/DMprecache.scr

	exec global/door_locked.scr::lock
	level.script = maps/dm/mohdm2.scr
	exec global/ambient.scr mohdm2
	
	level waittill spawn


mylite_thread: 
local.lite = spawn script_model model "fx_dummy.tik" 
local.lite.origin = ( 0 0 128 ) // coordinates 
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light). 
end


end

//-----------------------------------------------------------------------------

roundbasedthread:

	// Can specify different scoreboard messages for round based games here.

	level waitTill prespawn

	level waittill spawn

	// set the parameters for this round based match
	level.dmrespawning = 0 // 1 or 0
	level.dmroundlimit = 5 // round time limit in minutes
	level.clockside = kills // set to axis, allies, kills, or draw

	level waittill roundstart

end

why this doesn't work ? :?
console: Image
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post by Angex »

Try changing the model to "fx/dummy.tik":

Code: Select all

local.lite = spawn script_model model "fx/dummy.tik" 
Plus you should move the mylite_thread definition out your main thread, because I think that will also cause a problem.
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

Doesn't work with fx/dummy.tik

what do you exactly mean with

move the mylite_thread definition out your main thread

what is my main thread ? :oops:
User avatar
G3mInI
First Lieutenant
Posts: 187
Joined: Sat Jun 29, 2002 3:49 am

Post by G3mInI »

Like this:



// DESTROYED VILLAGE
// ARCHITECTURE: NED
// SCRIPTING: NED

main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Destroyed Village"
setcvar "g_obj_alliedtext2" ""
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" ""
setcvar "g_obj_axistext3" ""

setcvar "g_scoreboardpic" "mohdm2"


thread mylite_thread

// call additional stuff for playing this map round based is needed
if(level.roundbased)
thread roundbasedthread

level waittill prespawn

//*** Precache Dm Stuff
exec global/DMprecache.scr

exec global/door_locked.scr::lock
level.script = maps/dm/mohdm2.scr
exec global/ambient.scr mohdm2

level waittill spawn

end


//-----------------------------------------------------------------------------

roundbasedthread:

// Can specify different scoreboard messages for round based games here.

level waitTill prespawn

level waittill spawn

// set the parameters for this round based match
level.dmrespawning = 0 // 1 or 0
level.dmroundlimit = 5 // round time limit in minutes
level.clockside = kills // set to axis, allies, kills, or draw

level waittill roundstart

end

mylite_thread:
local.lite = spawn script_model model "fx/dummy.tik"
local.lite.origin = ( 0 0 128 ) // coordinates
local.lite light 1 1 1 300 // last number is how big it is, ( 1 1 1 is white light).
end

Your main thread is all the satements between main: and the first end statement, in this case I made it all in bold yellow type so you can see what the main thread consists of. So what you do is tell the script to call the thread mylite_thread before the end statement, highlighted in red text. It will jump down to that thread and do whatever and then jump back and continue on in the main thread. I placed this line here because if it were a roundbased game the very next line jumps down to the roundbased thread, and would skip over your thread statement if it came after it. This way, no matter what gametype you play, the thread will be exectued. Next you place the mylite_thread somewhere down the bottom of your script, outside of the boundaries of your main thread.

G3mInI
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

my bad

Post by tltrude »

Yes, it should be "fx/dummy.tik".
Tom Trude,

Image
Runt
First Lieutenant
Posts: 188
Joined: Wed Feb 11, 2004 5:03 pm
Location: The Netherlands
Contact:

Post by Runt »

It works fine now ! thanks !
SkiLLeT
Lance Corporal
Posts: 10
Joined: Mon Aug 02, 2004 1:46 am

Post by SkiLLeT »

Hello i need some help I made a fx/corona red and I used the blinking on then off method and it work great by the way. Now i need to figure out how to take the the fx/corona red out at the same time the light turns off. how can i do this? would i just put

mylite_thread:
local.lite = spawn script_model model "fx/corona_Red.tik" targetname mylight
local.lite.origin = ( 1514 2174 749.70 ) // coordinates
local.lite light 1 0 0 200 // last number is how big it is, ( 1 1 1 is white light).
thread blink_light
thread coronaoff
end

coronaoff:
wait 3
$mylight_thread remove
wait 3
thread mylight_thread
end

blink_light:

while(1)
{
$mylight lighton
wait 3
$mylight lightoff
wait 3
}
end


would that work or would the remove mylight thread disable the blinkingoff?
Post Reply