Creating an activator to lock and unlock a door.

Post » Wed Aug 17, 2011 4:14 am

Hi everyone,

I am trying to create a script for an activator using a switch (GenElecSwitch01 in GECK) which I have linked to a door (CabinMainDoor in GECK) to lock and unlock the door (So my companions can't just wander off and monsters can't just stroll in). I found this script online:


SCN LockDoorScript

Ref MyLink

Begin OnActivate

Set MyLink to GetLinkedRef

If MyLink.getOpenstate == 1

MyLink.setopenstate 0
MyLink.Lock 255

ElseIf MyLink.GetOpenState == 0

MyLink.Unlock
MyLink.SetOpenstate 1

EndIf

END


Since I am a complete novice when it comes to scripting, could someone please help me out and tell me how to get this to work? I am pretty sure that I need to replace 'MyLink' with the door's ref id or something but if someone could please clarify that it would be great. Thanks.
User avatar
Heather M
 
Posts: 3487
Joined: Mon Aug 27, 2007 5:40 am

Post » Wed Aug 17, 2011 2:01 pm

If you have the switch linked properly to the door, then you do not need to explicitly specify the reference name of the door, you can use the 'MyLink' just as you have it in the script.

So, if the script does nothing, and the script is actually attached to the switch, and 'that' switch is actually the one you are clicking in the world, and there is no script on the door object, then I suspect your linkage is not setup right.
User avatar
Horse gal smithe
 
Posts: 3302
Joined: Wed Jul 05, 2006 9:23 pm

Post » Wed Aug 17, 2011 2:48 am

It seems I'm still having a bit of trouble. I think the switch is linked to the door correctly because when I select it, an arrow points from the switch to the base of the door. I think it may be the script that is the problem. To clarify, to add a script to an object, I drag the object from the object window into the render window, then double click it, add linked reference, then click edit base and then click on the |...| box next to SCRIPT. Is that correct?
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am

Post » Wed Aug 17, 2011 9:45 am

Thats not the way I do it but it should work that way too.

What object is the 'CabinMainDoor'?
It must be a door object that has an open and close animation attached to it.
User avatar
daniel royle
 
Posts: 3439
Joined: Thu May 17, 2007 8:44 am

Post » Wed Aug 17, 2011 6:07 am

I'm editing the Hunters Ridge v.4 mod so 'CabinMainDoor' must be from that. I finally got it to work by the way. Thanks for the help :).
User avatar
Glu Glu
 
Posts: 3352
Joined: Sun Apr 01, 2007 5:39 am


Return to Fallout 3