Page 1 of 1
A nice basic scripting question for you all!
Posted: Sun Jun 20, 2004 8:25 am
by Mj
Ok, I have a bridge, that lifts as so>> ______ to __/ \__
And everything is sparkly and working
But, i can press this trigger more that once, and if i do, my bridge repeats itself... so it ends up all malformed, __\ /__ and in the wrong places.
How can I make my trigger ($switchtrigger) to only work when the script is not running, so no malformities occur.
Help would be much appreciated!
Mj
Posted: Sun Jun 20, 2004 9:14 am
by bdbodger
put $mytrigger nottriggerable at the top of the thread that opens the bridge and then put $mytrigger triggerable at the end after it is open . That is if you are useing setthread or you can just run a loop .
bridge_thread:
level.bridgeopen = 0
while(1)
{
$mytrigger waittill trigger
if(level.bridgeopen == 0)
{
waitthread open_bridge
level.bridgeopen = 1
}
else
{
waitthread close_bridge
level.bridgeopen = 0
} }
until it is reading the waittill trigger line activateing the trigger does nothing
Posted: Sun Jun 20, 2004 11:34 am
by Mj
O.o
Looks confusing! I have no idea how to apply this to my script!
My script is:
Code: Select all
bridge:
$switchspeaker playsound alarm_switch //makes a nice click
wait .5
$bridgespeaker loopsound lighthouse_run //whirrrrr
$rightsidebridge rotatez -20
$leftsidebridge rotatez 20 //rotates
wait 3.5
$rightsidebridge rotatez 0 //stops rotation
$leftsidebridge rotatez 0
$bridgespeaker loopsound lighthouse_run wait //stops whirrrrr
$switchspeaker playsound alarm_switch //makes a nice clicky sound
wait 15
$bridgespeaker loopsound lighthouse_run //whirrrrr
$rightsidebridge rotatez 20
$leftsidebridge rotatez -20 //rotates
wait 3.5
$rightsidebridge rotatez 0 //stops rotation
$leftsidebridge rotatez 0
$bridgespeaker loopsound lighthouse_run wait //stops whirrrrr
$switchspeaker playsound alarm_switch //makes a nice clicky sound
I made this myself

(yes i am proud) and i put the // for anyone who wants to make the bridge too
How can i transer your script into this script?
Thanks a lot,
Mj
Posted: Sun Jun 20, 2004 2:15 pm
by Elgan
i think this is ok. hope it is
Code: Select all
bridge_thread:
level.bridgeopen = 0
while(1)
{
$mytrigger waittill trigger
if(level.bridgeopen == 0)
{
$mytrigger nottriggerable //i added this as i think maybe u could keep pressing it and it would rotate out place
waitthread open_bridge
level.bridgeopen = 1
$mytrigger triggerable
}
else
{
$mytrigger nottriggerable //i added this as i think maybe u could keep pressing it and it would rotate out place
waitthread close_bridge
level.bridgeopen = 0
$mytrigger triggerable
}
}
end
open_bridge:
$switchspeaker playsound alarm_switch //makes a nice click
wait .5
$bridgespeaker loopsound lighthouse_run //whirrrrr
$rightsidebridge rotatez -20
$leftsidebridge rotatez 20 //rotates
wait 3.5
$rightsidebridge rotatez 0 //stops rotation
$leftsidebridge rotatez 0
$bridgespeaker loopsound lighthouse_run wait //stops whirrrrr
$switchspeaker playsound alarm_switch //makes a nice clicky sound
end
close_bridge: //seperated out from the first thread so u are able to open and close it from the trigger
$bridgespeaker loopsound lighthouse_run //whirrrrr
$rightsidebridge rotatez 20
$leftsidebridge rotatez -20 //rotates
wait 3.5
$rightsidebridge rotatez 0 //stops rotation
$leftsidebridge rotatez 0
$bridgespeaker loopsound lighthouse_run wait //stops whirrrrr
$switchspeaker playsound alarm_switch //makes a nice clicky sound
end
Posted: Sun Jun 20, 2004 2:20 pm
by Mj
Thanks a lot!
I'll go and give it a shimmy now
Mj
EDIT: Yay! it works! Party!
Thanks Elgan!
rotate
Posted: Sun Jun 20, 2004 4:14 pm
by tltrude
That is pretty complicated for such a simple bridge. Let me introduce you to a new set of commands.
$rightsidebridge rotateZup 30
$rightsidebridge move
$rightsidebridge rotateZdown 30
$rightsidebridge move
If Z does not rotate it the right way, try X or Y--or negitive numbers. With these commands you do not have to time the move and then stop it. The time it takes them to move can be set with the command "time"--like this.
$rightsidebridge time 2.5
$leftsidebridge time 2.5
That only has to be set once, unless you want to change the travel time for some reason.
I see you have your trigger using a setthread, That is not needed for a trigger_use because the thread will auttomattically wait for the trigger to be used. Put "thread bridge_thread" under "level waittill prespawn" to start the thread waiting. Then this line will make it wait.
$mytrigger waittill trigger // "mytrigger" would be the targetname of your trigger_use.
You can also put that line more than once in a thread.
$mytrigger waittill trigger
//do the open lines
$mytrigger waittill trigger
//do the close lines
So your trigger will both open and close the bridge. But it might be better to just put in a wait line and have it close by itself.
$mytrigger waittill trigger
//do the open lines
wait 5
//do the close lines
So, here is a thread that will do the same as you had it--almost.
//=============================================
local.master = spawn ScriptMaster
local.master aliascache door_vault_roll_open sound/mechanics/m6l3a_SlidingDoors_Open.wav soundparms 1.0 0.0 1.0 0.0 160 1600 item loaded maps "m dm moh obj train"
level waittill prespawn
$rightsidebridge time 2.5
$leftsidebridge time 2.5
thread bridge_thread
etc....
//=============================================
//----------------------------------------------------------->
// bridge thread
//----------------------------------------------------------->
bridge_thread:
$mytrigger waittill trigger
$switchspeaker playsound alarm_switch //makes a nice click
wait .5
$rightsidebridge playsound door_vault_roll_close // works best with time 2.5
$rightsidebridge rotateZup 30
$rightsidebridge move
$leftsidebridge playsound door_vault_roll_close
$leftsidebridge rotateZup -30
$leftsidebridge waitmove
wait 8
$bridge_right_speaker playsound door_vault_roll_close
$rightsidebridge rotateZdown 30
$rightsidebridge move
$leftsidebridge playsound door_vault_roll_close
$leftsidebridge rotateZdown -30
$leftsidebridge waitmove
$switchspeaker playsound alarm_switch //makes a nice click
goto bridge_thread
end
//=============================================
Hope that helps you understand it a little better!
Posted: Sun Jun 20, 2004 5:48 pm
by Mj
O.o
I managed to comprehend it on the 4th read through!
Thanks t|trude! I knew there was a rotate simple one, but i couldnt find it!
My map, (with two of Elgans scripted bridges (it works, and i dont want to jepordise it

)) FastAndFurious2 will be on later tonight, and i will post it in the review section for those who wish to view it (and i would like a review

)
Thanks again chaps,
Mj