unlock door from somewhere else

Post your scripting questions / solutions here

Moderator: Moderators

solar
Colour Sergeant
Posts: 99
Joined: Fri Mar 21, 2003 2:40 pm
Location: Toledo, OH

Post by solar »

Actually, I have in place the alarm switch with the lever that goes up and down. I was going to try "switch anim turn". Will that not work?
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Alarm switch

Post by tltrude »

For one of those it would be

$switch anim turnoff

Provided you alarm switch is target named "switch". Acctually, the word switch is a command word and it might be better to targetname it "door_lock_switch". If you highlight the switch in the editor and click on key N and the "Anim:" pluse and minus buttons, you will see all the test animation words you can use for it.
Tom Trude,

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

A door will automatically play the locked sound when it's triggered but locked ;) (works for all doors - rotating / sliding).

Like tltrude said don't use 'switch' as a targetname.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

sound

Post by tltrude »

Yes, but it would be nice if it, or the switch, made a sound to tell the player it is now unlocked. Could also use a red cage light. Too bad there is not green cage light.
Tom Trude,

Image
solar
Colour Sergeant
Posts: 99
Joined: Fri Mar 21, 2003 2:40 pm
Location: Toledo, OH

Post by solar »

Well, here's what I have so far:

1. func_rotating door with
"targetname - locked_door"

2. alarm switch model with
"targetname - plansdoor_switch" and
"testanim - idle"

3. door trigger_use covering the alarm switch with
"targetname - door_switch_trigger" and
"setthread- door_switch"

So far the relevant parts of my script look like this:

script:
main:

level waittill prespawn

$locked_door lock
$locked_door.locked = 1
end

level waittill spawn

door_switch:
if ($locked_door.locked)
{
$locked_door.locked = 0
$locked_door unlock
}
else
{
$locked_door.locked = 1
$locked_door lock
}
end
How's that look? I also can't figure where to put the animation part of the script. I'm thinking something like this:
door_switch:

$door_switch_trigger waittill trigger
$door_switch_trigger remove
$plansdoor_switch anim turnoff
$plansdoor_switch playsound alarm_switch

if ($locked_door.locked)
{
$locked_door.locked = 0
$locked_door unlock
}
else
{
$locked_door.locked = 1
$locked_door lock
}
end
Something like that, but I know there's probably some error there.
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

why

Post by tltrude »

Jv_map's thread can both unlock and lock the door, so why are you removing the trigger? Do you want the door to be relockable or not?

Code: Select all

main:

level waittill prespawn

$locked_door lock
thread door_switch

level waittill spawn

end

door_switch: 

$door_switch_trigger waittill trigger 
$door_switch_trigger remove 
$plansdoor_switch playsound alarm_switch
$plansdoor_switch anim turnoff 
$locked_door unlock 

end
You will have to take the setthread off the trigger for this script to work.
Tom Trude,

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Your 'level waittill spawn' is a little loose solar ;), tltrude has it better :)
Image
Post Reply