Scripted light

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Scripted light

Post by HDL_CinC_Dragon »

ok i got a light that is a script_model and it has the
model: fx/dummy.tik
classname: script_model
targetname: light

and then theres a trigger multiple in the map that when the player walks into it the light goes through RGB cycling every .5 seconds in some mad epileptic thing lol. but the multiple has
targetname: lighter

and heres the .scr

Code: Select all

Main:

setcvar "g_obj_alliedtext1" "Epilepsy"
setcvar "g_obj_alliedtext2" "Warning"
setcvar "g_obj_alliedtext3" "RGB"
setcvar "g_obj_axistext1" "Epilepsy"
setcvar "g_obj_axistext2" "Warning"
setcvar "g_obj_axistext3" "RGB"

setcvar "g_scoreboardpic" "none"

	level waittill prespawn
		thread light_ops
		$light light 400

	level waittill spawn

light_ops:
while(1)
	{
		$lighter waittill trigger
		$lighter nottriggerable
		$light _color 1.000000 0.000000 0.000000
		wait .5
		$light _color 0.000000 1.000000 0.000000
		wait .5
		$light _color 0.000000 0.000000 1.000000
		wait .5
		waitframe
	}
end
Tell me what I did wrong. This is my first attempt at light scripting.

the map is title light_test.map the script is titled light_test.scr. I put \\ in front off all the actuall scripting stuff except the "main:" and the "setcvar" things to see if the light script was messin it up but the whole thing didnt work... curious...
I use "Mohaa Script Editor" to write my scripts now... i like it =). but do u think that has anything to do with it?
Last edited by HDL_CinC_Dragon on Wed Feb 02, 2005 2:48 am, edited 1 time in total.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

make sure you're not trying to give the trigger AND the light values and such..
the light is wrote:targetname: light
the trigger is wrote:targetname: light
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

oops the triggers targetname is "lighter" not "light" sry ill fix that in the thing up there.
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

try this

Code: Select all

level waittill prespawn
      thread light_ops

   level waittill spawn
end

light_ops:

      $lighter waittill trigger
      $lighter triggerable
      $light light 1 0 0 250//red 1 0 0 //color// 250 radius
      wait .5
      $light light 0 1 0 250//green
      wait .5
      $light light 0 0 1 250//blue
      wait .5
      $lighter nottriggerable
      goto light_ops
end
this code works if the targetnames are correct to the ones above.im not good at the while(1) { }stuff...lol
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

forget goto...

just do this instead

Code: Select all

while(1)
{
// code
}
it's much more controllable with a variable, but people seem to like 1 better.
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:

light

Post by tltrude »

It is probably not a good idea to targetname the light as "light"--"light_01" or "light_bulb" might be better.

Green Beret's script should work well, except I think he has the triggerable and nottriggerable lines reversed. Actually, those two lines are not needed at all because the trigger will not be checked again until the thread is reset by the goto line.
Tom Trude,

Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

yeah the triggerable and nottriggerable lines are backwards and i use the while(1) stuff and things like that and ill change the targetname of light to light_01.
I wasnt that great at whe While(1) stuff either but i think im gettin the hang of it =)
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

ok heres my .scr so far:

Code: Select all

main:

setcvar "g_obj_alliedtext1" "Epilepsy"
setcvar "g_obj_alliedtext2" "Warning"
setcvar "g_obj_alliedtext3" "RGB"
setcvar "g_obj_axistext1" "Epilepsy"
setcvar "g_obj_axistext2" "Warning"
setcvar "g_obj_axistext3" "RGB"

setcvar "g_scoreboardpic" "none"

	level waittill prespawn
		thread light_ops

	level waittill spawn

light_ops:
while(1)
	{
		$lighter waittill trigger
		$lighter nottriggerable
		$light_01 _color 1.000000 0.000000 0.000000 250
		wait .5
		$light_01 _color 0.000000 1.000000 0.000000 250
		wait .5
		$light_01 _color 0.000000 0.000000 1.000000 250
		wait .5
		$lighter triggerable
		waitframe
	}
end
this time, instead of a trigger_multiple and i have a trigger_use with this:
Image (click to enlarge).

but yeah when i press the button nothing happens...
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You are useing the wrong values for this type of a dynamic light source . Try this instead

light_ops:
while(1)
{
$lighter waittill trigger
$lighter nottriggerable
$light_01 light 1 0 0 250
$light_01 lighton
wait .5
$light_01 light 0 1 0 250
wait .5
$light_01 light 0 0 1 250
wait .5
$lighter triggerable
waitframe
}
end

If you want the light to start on put

$light_01 light 1 0 0 250
$light_01 lighton

above the while(1) as well . You can just do $light_01 lightoff when you want it to shut off
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

im not the most expierienced here,but i think u need to add end after
level waittill spawn
i usually get better results doin it like that.but it sounds like BD is the one to listen to on this one.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

end is to close threads, main is a thread, ONLY use end when that thread is done. if you have nothing but thread calls after level waittill spawn. definitely use end there. otherwise, you only have one thread *shrug*
so end it anyway, you need an end to enclose every thread.
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Green Beret wrote:im not the most expierienced here,but i think u need to add end after
level waittill spawn
i usually get better results doin it like that.but it sounds like BD is the one to listen to on this one.
yes, definately! so, it should be

Code: Select all

main: 

setcvar "g_obj_alliedtext1" "Epilepsy" 
setcvar "g_obj_alliedtext2" "Warning" 
setcvar "g_obj_alliedtext3" "RGB" 
setcvar "g_obj_axistext1" "Epilepsy" 
setcvar "g_obj_axistext2" "Warning" 
setcvar "g_obj_axistext3" "RGB" 

setcvar "g_scoreboardpic" "none" 

   level waittill prespawn 
      thread light_ops 

   level waittill spawn
end 

light_ops: 
while(1) 
{ 
$lighter waittill trigger 
$lighter nottriggerable 
$light_01 light 1 0 0 250 
$light_01 lighton 
wait .5 
$light_01 light 0 1 0 250 
wait .5 
$light_01 light 0 0 1 250 
wait .5 
$lighter triggerable 
waitframe 
} 
end 
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

I would just like to say: "I LOVE YOU ALL!" it works now =) I added the "lighton" and changed the "_color" to "light" and all that goodness =) it does everything i want it to! Thnx guys! until next time.

Code: Select all

main:

setcvar "g_obj_alliedtext1" "Epilepsy"
setcvar "g_obj_alliedtext2" "Warning"
setcvar "g_obj_alliedtext3" "RGB"
setcvar "g_obj_axistext1" "Epilepsy"
setcvar "g_obj_axistext2" "Warning"
setcvar "g_obj_axistext3" "RGB"

setcvar "g_scoreboardpic" "none"

	level waittill prespawn
		thread light_ops
		$light_01 lightoff

	level waittill spawn
end

light_ops:
while(1)
	{
		$lighter waittill trigger
		$lighter nottriggerable
		$light_01 light 1.000000 0.000000 0.000000 250
		$light_01 lighton
		wait .5
		$light_01 light 0.000000 1.000000 0.000000 250
		wait .5
		$light_01 light 0.000000 0.000000 1.000000 250
		wait .5
		$light_01 lightoff
		$lighter triggerable
		waitframe
	}
end
Image
Green Beret
Major General
Posts: 746
Joined: Mon Apr 19, 2004 12:21 pm
Contact:

Post by Green Beret »

Congrats,i love it how people like helpin till its working! 8-)
Image
User avatar
HDL_CinC_Dragon
Brigadier General
Posts: 574
Joined: Mon Dec 22, 2003 8:32 pm

Post by HDL_CinC_Dragon »

lol me too :D :D
Image
Post Reply