Need Script for script/object Trapdoor with remote trigger

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
CDG
Private
Posts: 1
Joined: Fri Jan 20, 2006 12:41 am

Need Script for script/object Trapdoor with remote trigger

Post by CDG »

I am a new mapper and trying to learn scripting. Cut and paste scripting has got most of the stuff done, but I would rather understand why and how stuff is scripted. For now, I would settle for someone to volunteer a ready made script for a script/object trapdoor that toggles open or closed and is operated from a remote trigger!
Phantomwarrior
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I assume maybe that you know already how to make a normal rotateing door ? Makeing a trap door is simular to that but not exactly the same . You make the brush for the door and a brush with the origin texture on it that will act as the hindge . With both of those selecte you make them a script object then create a trigger use or trigger multiple which ever you need for what you are doing . Deselect everything then select your trigger first then one part of the script object and use control k you should then see a line from the trigger to the script object . Ok that is the mapping part now the scripting part . When you make a script object it's angles are ( 0 0 0 ) the starting position so to speak . Now if from the hindge to the middle of the trap door is toward the right or left side of the editor in the top view then you will rotateing on the x axis . If from the hindge to the middle of the door is toward the top or bottom in the editor in the top view then you will be rotateing on the z axis . It is like this ( x y z ) ( pitch yaw roll) . If from the hindge to the middle of the trap door is toward the right side you will be pitching , + pitches forward and down - pitches backward and up . It will be rotateing at the point that you put the origin brush .Ok still assumeing from the hindge to the middle of the trap door is toward the right we want to use - pitch to go from closed to open . Make sure your trigger has a targetname . Ok now the scripting .

main:

thread trap_door

end

trap_door:

while(1) // a continuous loop to run the door
{

$my_trigger waittill trigger // thread waits for your trigger to be triggered

$my_trigger.target rotatexupto -90

// ok this is the pitch stuff up and back 90 degrees not sure at the moment if you need to use rotatexupto -90 or rotatexdownto -90 you can even use rotatexup -90 or rotatexdown -90 the difference is rotatexupto -90 is 90 degrees straight up no matter what angle the script object was before where as rotatexup - 90 rotates it back 90 degrees from where it is at the moment if it was down 10 it will end up at -80 degrees not -90

wait 5 // you can also use $my_trigger waittill trigger again if you want the door to close only when the trigger is triggered again

$my_trigger.target rotatexdownto 0 // or in the case of rotatexup -90 you need to then rotatexdown 90 to get it back down to where it started rotatexdownto 0 ( degeees ) is absolute back to level again
}

end

// So you see the main thing is which direction it will rotate forward or back to the left or to the right ( rotatexupto , rotatexup , rotatexdownto rotatexdown , rotatezupto or rotatezup etc etc )

Hope that helps a bit try it and if you run into problems come back with what you have done .
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

OH I forgot to add a move command to the script after the rotate command and you can also add a time command to control how fast to move

main:

thread trap_door

end

trap_door:

while(1) // a continuous loop to run the door
{

$my_trigger waittill trigger // thread waits for your trigger to be triggered

$my_trigger.target rotatexupto -90

$my_trigger.target time 1 // one second
$my_trigger.target move


// ok this is the pitch stuff up and back 90 degrees not sure at the moment if you need to use rotatexupto -90 or rotatexdownto -90 you can even use rotatexup -90 or rotatexdown -90 the difference is rotatexupto -90 is 90 degrees straight up no matter what angle the script object was before where as rotatexup - 90 rotates it back 90 degrees from where it is at the moment if it was down 10 it will end up at -80 degrees not -90

wait 5 // you can also use $my_trigger waittill trigger again if you want the door to close only when the trigger is triggered again

$my_trigger.target rotatexdownto 0 // or in the case of rotatexup -90 you need to then rotatexdown 90 to get it back down to where it started rotatexdownto 0 ( degeees ) is absolute back to level again

$my_trigger.target move
}

end
Image
Phantomwarrior
Corporal
Posts: 27
Joined: Fri Jan 20, 2006 1:42 am
Location: Bakersfield, California

Thanks for Trapdoor help

Post by Phantomwarrior »

Thanks for the input, I was able to make my turnstile work like a charm with this variation of the trapdoor scripts:

Under main setthreads,
thread turnstile_prep

//trigger in pillbox is (setthread turnstile_standby) in trigger entity window
turnstile_prep:

$turnstile_arm bind $turnstile
level.turnstile_pos = 0 // Defines the position of the turnstile. "0 - down" "1 - up"
$turnstile_trigger wait 10.2 //sets trigger

goto turnstile_standby // standing by for player to activate the trigger
//-----------------------------------------------------------------------

turnstile_standby:

$turnstile_trigger waittill trigger
if (level.turnstile_pos == 0) // If turnstile position is down, use this thread.
{
println "turnstile down - moving up" //prints to console if the developer mode is set.
goto turnstile_move_up

end
}
else
if (level.turnstile_pos == 1) // if turnstile position is up, use this thread.
{
println "turnstile up - moving down" //prints to console if the developer mode is set.
goto turnstile_move_down

end
}

end
//---------------------------------------------------------------------------

turnstile_motor:

$turnstile_motor loopsound turnstile_motorxx
wait 10.1
$turnstile_motor stoploopsound turnstile_motorxx

end
//---------------------------------------------------------------------------

turnstile_move_up:

$turnstile_trigger wait 10.2
thread turnstile_motor
$turnstile rotateXdownto -80
$turnstile time 10
$turnstile waitmove

level.turnstile_pos = 1 // set the turnstile_pos to up

goto turnstile_standby

end
turnstile_move_down:

$turnstile_trigger wait 10.2
thread turnstile_motor
$turnstile rotateXupto 0
$turnstile time 10
$turnstile waitmove

level.turnstile_pos = 0 // set the turnstile_pos to down

goto turnstile_standby

end
Phantomwarrior
Post Reply