spawning a light entity?
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?
How would you script-spawn a light. Not a static light model but the actual LIGHT. Could someone help me a little?
._
/..\
\_/
._
/..\
\_/
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.
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
spawn a Dynamic light
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
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.
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
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
-
nuggets
- General
- Posts: 1006
- Joined: Fri Feb 28, 2003 2:57 am
- Location: U-england-K (england in the UK) :P
- Contact:
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
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
-
Runt
- First Lieutenant
- Posts: 188
- Joined: Wed Feb 11, 2004 5:03 pm
- Location: The Netherlands
- Contact:
hey, a bit late reply .. but i need help..
why this doesn't work ?
console:
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
console:

Try changing the model to "fx/dummy.tik":
Plus you should move the mylite_thread definition out your main thread, because I think that will also cause a problem.
Code: Select all
local.lite = spawn script_model model "fx/dummy.tik"
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
// 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
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?
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?


