MelThorn Posted June 11, 2015 Share Posted June 11, 2015 (edited) Say I wanted a door to be locked, but the only way to unlock it is to activate something, like a pedestal outside. Could that be done? Or would I absolutely have to use a key? Is there maybe a script for detecting whether a door is locked or unlocked, and telling it to switch to either of those via an activator? I'm thinking of possibly creating two doors and using a script to disable and enable one or the other with an X marker, but I wanted to know if there was another way. I really don't want to use a key, but if that's the only way, I'll do it. I just want to know if using a scripted activator is possible to unlock a door. Thanks. Edited June 11, 2015 by MelThorn Link to comment Share on other sites More sharing options...
skinnytecboy Posted June 11, 2015 Share Posted June 11, 2015 (edited) There are already activators that do this in the game. Take look in the warehouse cells in CK (can't remember the name of the actual one that features levers and doors). Take a peek at one and see how it works. Basically you need to set up a lever as a "parent" and point it to your door. You'll see a thin blue line if you do it right. You can set your door as locked (key) but you won't need a key to actually open it. Alternatively you can add your own script to a lever: Add a property that points to the door Door property MyDoor auto OnActivate(blah blah)Event MyDoor.lock(false) MyDoor.SetOpen()EndEvent Still you're best taking the first option and getting to know how things work. We learn by doing ;) There's a slightly more complex example here:http://www.creationkit.com/Complete_Example_Scripts#A_Fully_Functional_Dwemer_Button Edited June 11, 2015 by skinnytecboy Link to comment Share on other sites More sharing options...
MelThorn Posted June 11, 2015 Author Share Posted June 11, 2015 Thanks for the reply :)It'll serve me well in the future. Link to comment Share on other sites More sharing options...
MelThorn Posted June 11, 2015 Author Share Posted June 11, 2015 (edited) I believe that "lock" needs a function. At least, that's what the compiler is telling me. And I'm pretty sure I can't have a function inside of an event. Trying to get it to work, but... :wallbash:What I'm trying to accomplish is a door unlocking once a lexicon is placed on a pedestal. I can get as far as scripting the receptacle into taking my lexicon, but I can't figure out how to fit unlocking the door into all of that mess. It's starting to become more trouble than it's worth, and I might just end up using a key. One of the reasons why I didn't want to use a key was because I thought it was silly that a door hundreds of years old would open with just some key. Here's the script I have for putting the lexicon down: Scriptname VANCHStandBlueScript extends ObjectReference {Activates the blue lexicon stand outside of Vanchngark.}MiscObject Property VANCHCubeBlue autoActor Property PlayerRef autoGlobalVariable Property LexiconPlaced autoAuto State ActivationEvent OnActivate(ObjectReference akActionRef) if LexiconPlaced.GetValue() == 0 if (akActionRef == PlayerRef) && (PlayerRef.GetItemCount(VANCHCubeBlue) > 0) GotoState("Busy") LexiconPlaced.SetValue(1) PlayerRef.RemoveItem(VANCHCubeBlue, 1) PlayAnimation("setdown") Utility.Wait(0.5) PlayAnimation("open") Utility.Wait(2) GotoState("Activation") endif elseif LexiconPlaced.GetValue() == 1 if (akActionRef == PlayerRef) GotoState("Busy") PlayAnimation("close") Utility.Wait(1) PlayAnimation("pickup") Utility.Wait(0.5) PlayerRef.AddItem(VANCHCubeBlue, 1) LexiconPlaced.SetValue(0) GotoState("Activation") endif endifEndEventEndStateState BusyEndState I also can't take the lexicon back once I've put it on the stand, either. The script makes it look like you can, but it won't let me.This is starting to not be worth the entire day I've wasted on trying to figure this out, and I might just go with a key after all. Edited June 11, 2015 by MelThorn Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted June 12, 2015 Share Posted June 12, 2015 The only reasons I can see you not being able to pick the lexicon cube back up. Did you assign the LexiconPlaced globalvariable property in CK?If so then did you run the script on a clean save, eg: not run the script before filling the LexiconPlaced globalvariable property in CK. Might be also, not sure.GetValue() is returning a float, your comparing against an intMaybe try If LexiconPlaced.GetValueInt() == 0 and ElseIf LexiconPlaced.GetValueInt() == 1Or use If !LexiconPlaced.GetValue() and ElseIf LexiconPlaced.GetValue()Or use If LexiconPlaced.GetValue() == 0.0 and ElseIf LexiconPlaced.GetValue() == 1.0As for when to unlock and lock the door: MiscObject Property VANCHCubeBlue auto Actor Property PlayerRef auto GlobalVariable Property LexiconPlaced auto ObjectReference Property myDoor Auto ; <--- Point this to your door reference you want to lock and unlock. Auto State Activation Event OnActivate(ObjectReference akActionRef) if !LexiconPlaced.GetValue() if (akActionRef == PlayerRef) && (PlayerRef.GetItemCount(VANCHCubeBlue) > 0) GotoState("Busy") LexiconPlaced.SetValue(1) myDoor.Lock(False) PlayerRef.RemoveItem(VANCHCubeBlue, 1) PlayAnimation("setdown") Utility.Wait(0.5) PlayAnimation("open") Utility.Wait(2) GotoState("Activation") endif elseif LexiconPlaced.GetValue() if (akActionRef == PlayerRef) GotoState("Busy") PlayAnimation("close") Utility.Wait(1) PlayAnimation("pickup") Utility.Wait(0.5) PlayerRef.AddItem(VANCHCubeBlue, 1) LexiconPlaced.SetValue(0) myDoor.Lock(True) GotoState("Activation") endif endif EndEvent EndState State Busy EndState Link to comment Share on other sites More sharing options...
MelThorn Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) Thanks a bunch for the reply and the help.I'll be honest-- I don't know how to assign the LexiconPlaced property. I auto-filled the others just fine, but I'm not sure how to deal with the GlobalVariable. I'm still fairly new to making mods, so I'm a little clueless on what I should do for that particular property. I did try your suggested script with simply GetValue() without an integer, but I still couldn't pick up the lexicon after placing it. I could give the alternative Int version a shot or two before the night is over to see if either of those work. I'll assume that if the Int version doesn't work, it's probably the GlobalVariable issue. Thanks again for the helpful advice :smile: Update: the Int version didn't seem to do the trick, either. So I'm guessing it might be the assigned property problem.The good news is that the lexicon unlocked the door like I originally wanted. Thanks for getting me to that point! Edited June 13, 2015 by MelThorn Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted June 13, 2015 Share Posted June 13, 2015 Since I don't feel like explaining the GlobalVariable to you, I'll make it easy instead.Try this script, all you need to do is:1) Compile script.2) Attach Compiled script to your Lexicon Stand activator.3) Fill the 2 Properties (VANCHCubeBlue and myDoor) in CK. Should work, let me know. Scriptname VANCHStandBlueScript extends ObjectReference {Activates the blue lexicon stand outside of Vanchngark.} MiscObject Property VANCHCubeBlue auto ObjectReference Property myDoor Auto ; <--- Point this to your door reference you want to lock and unlock. Bool bLexiconPlaced Auto State Activation Event OnActivate(ObjectReference akActionRef) If Game.GetPlayer() == akActionRef GotoState("Busy") If !bLexiconPlaced Game.GetPlayer().RemoveItem(VANCHCubeBlue, 1) PlayAnimation("setdown") Utility.Wait(0.5) PlayAnimation("open") Utility.Wait(2.0) ElseIf bLexiconPlaced PlayAnimation("close") Utility.Wait(1.0) PlayAnimation("pickup") Utility.Wait(0.5) Game.GetPlayer().AddItem(VANCHCubeBlue, 1) EndIf myDoor.Lock(bLexiconPlaced) bLexiconPlaced = !bLexiconPlaced GotoState("Activation") EndIf EndEvent EndState State Busy EndState Link to comment Share on other sites More sharing options...
MelThorn Posted June 13, 2015 Author Share Posted June 13, 2015 That script you gave me did work. I was able to place the lexicon, it unlocked the door, and I was able to take it back off to lock the door again.The only problem now is that it will take a lexicon whether I have one in my inventory or not. It just spawns one and places it down. Everything else works perfectly, though. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted June 13, 2015 Share Posted June 13, 2015 Scriptname VANCHStandBlueScript extends ObjectReference {Activates the blue lexicon stand outside of Vanchngark.} MiscObject Property VANCHCubeBlue auto ObjectReference Property myDoor Auto ; <--- Point this to your door reference you want to lock and unlock. Bool bLexiconPlaced Auto State Activation Event OnActivate(ObjectReference akActionRef) If (Game.GetPlayer() == akActionRef) GotoState("Busy") If !bLexiconPlaced && (Game.GetPlayer().GetItemCount(VANCHCubeBlue) > 0) Game.GetPlayer().RemoveItem(VANCHCubeBlue, 1) PlayAnimation("setdown") Utility.Wait(0.5) PlayAnimation("open") Utility.Wait(2.0) myDoor.Lock(bLexiconPlaced) bLexiconPlaced = !bLexiconPlaced ElseIf bLexiconPlaced PlayAnimation("close") Utility.Wait(1.0) PlayAnimation("pickup") Utility.Wait(0.5) Game.GetPlayer().AddItem(VANCHCubeBlue, 1) myDoor.Lock(bLexiconPlaced) bLexiconPlaced = !bLexiconPlaced EndIf GotoState("Activation") EndIf EndEvent EndState State Busy EndState Link to comment Share on other sites More sharing options...
MelThorn Posted June 13, 2015 Author Share Posted June 13, 2015 Awesome! Works great. Thanks for all the help! :thumbsup: Link to comment Share on other sites More sharing options...
Recommended Posts