Page 1 of 1

Lighting Sequence

Posted: Wed May 04, 2005 8:23 pm
by HDL_CinC_Dragon
ok, what I have is a series of lights hooked up to one switch and theyre all going up the side of a smoke stack. i want it so that when the player hits the trigger, the bottom light turns on, then a secoond later it turns off just as the second light turns on, then a second later it turns off just as the third light is turning on, and so and so forth for as many lights as I have it. I need a little bit of help with the script


What i have normally is:

Code: Select all

main:

level waittill prespawn

thread light_ops
$light_01 light 1 0 0 150
$light_02 light 1 0 0 150
$light_03 light 1 0 0 150
$light_01 lightoff
$light_02 lightoff
$light_03 lightoff

level waittill spawn

light_ops
while(1)
{
$light_01 lighton
wait 1
$light_01 lightoff
$light_02 lighton
wait 1
$light_02 lightoff
$light_03 lighton
wait 1
$light_03 lightoff
waitframe
}
end
and everything works fine and dandy. But now i want to mak it so this can be turned off and im not quite at the script testing stage yet.

Can you tell me if this would work:

Code: Select all

main:

level waittill prespawn

thread light_ops
$light_01 light 1 0 0 150
$light_02 light 1 0 0 150
$light_03 light 1 0 0 150
$light_01 lightoff
$light_02 lightoff
$light_03 lightoff

level waittill spawn

light_ops
$trigger_01 waittill trigger
while(1)
{
$light_01 lighton
wait 1
$light_01 lightoff
$light_02 lighton
wait 1
$light_02 lightoff
$light_03 lighton
wait 1
$light_03 lightoff
waitframe
}
end
If this will work plz dont tell me about some way that includes level.light doing this and this while this equals that and all that stuff. im not good at that.... Thnx.

Dragon

Posted: Wed May 04, 2005 9:21 pm
by lizardkid
Every thread you have you need a : for.
light_ops

Code: Select all

light_ops: 
Both your version and this version work fine, but a more "universally accepted" coding way is to never make your intention apparent. always use loops and such when possible.

There were also some errors in double-threading (putting more than one thread inside one)

you also called the light_ops thread before initializing the lights.



Code: Select all

main: 

level waittill prespawn 

$light_01 light 1 0 0 150 
$light_02 light 1 0 0 150 
$light_03 light 1 0 0 150
$light_01 lightoff 
$light_02 lightoff 
$light_03 lightoff 

level.lightIsGoing = "TRUE" // always include a "control variable"

level waittill spawn 

thread light_ops

end

light_ops: 
// handles the lights

while(level.isLightGoing == "TRUE") 
{ 
$light_01 lighton 
wait 1 
$light_01 lightoff 
$light_02 lighton 
wait 1         // lengthy series of light on and offs, but there's no other way.
$light_02 lightoff 
$light_03 lighton 
wait 1 
$light_03 lightoff 
waitframe 
} 
end

Posted: Wed May 04, 2005 10:03 pm
by HDL_CinC_Dragon
Thnx man. And oh yeah, I know about how you need colons (:) for all the threads I just typed that one up for a quick example =) But yeah ill try both just in case =) Thnx

Posted: Thu May 05, 2005 1:43 am
by bdbodger
you may want to turn it back on again and how did you say you where going to turn it off ? Maybe something like this : use the setthread key on $trigger_01 to run this thread

mythreadname:

if(level.lightIsGoing = "TRUE")
level.lightIsGoing = "False"
else
{
level.lightIsGoing = "TRUE"
thread light_ops
}
end

light_ops:

while(level.isLightGoing == "TRUE")
{
$light_01 lighton
wait 1
$light_01 lightoff
$light_02 lighton
wait 1 // lengthy series of light on and offs, but there's no other way.
$light_02 lightoff
$light_03 lighton
wait 1
$light_03 lightoff
wait 1
}
end

Posted: Thu May 05, 2005 8:10 pm
by HDL_CinC_Dragon
thnx! thats exactly what I wanted! Both of you. Thnx