Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

9 Key Combination Lock


DsoS
 Share

Recommended Posts

I am wondering how this looks, and wondering if someone would be nice enough to run it through the CK compiler and see if any errors are thrown and if so, post those errors.

The laptop that I am currently using will not handle skyrim or even the CK due to it only having roughly 1Gb of ram. My main computer power supply blew up. I won't be able to get a new one for a couple of weeks. :( 1 of the large capicators blew up, nearly gave me a heartattack when it happened at about 2:30am LOL . Neighbors heard it also and thought someone had fired a shotgun!!!

Luckily none of the other componenents seemed to have been messed up. I tested with a friends power supply that he brought over out of his main computer! Thank You Justin!

Anyway for this script, the notes are as follows:
* The 9 Global Variables are on 9 buttons.
* This script is placed on a button.

-[Does the script look correct?]
-[is there a better way to do any of the parts in the script?]
-[On the very bottom of the script is a long list, what would be the best way to check to ensure that the user has not selected more than ONE Bool for Slide Direction? I will most likely have it default to disable the MyItem if they have and give the warning message box that is already in the code.]
-[The "Event OnInit()" section, the first 8 lines (excluding the comments) are a concern to me, is that the correct way to use them?]

 

If any other info is needed please let me know!

 

Thank You,

DSoS

ScriptName aaDSoSRandomComboLock extends ObjectReference

{Adds a functional 9-button combo lock in game to unlock secret locations or unlock/open gates, etc.
Requires 9 buttons of any type, in a T9 keypad configuration, as such:
123
456
789}
 
Import Game
Import Utility
Import Debug
 
 ObjectReference Property MyItem Auto
 {This is the item that the Combo Lock will, unlock, disable or slide open.}
 
;Top Buttons
ObjectReference Property Button1TopLeft Auto
ObjectReference Property Button2TopCenter Auto
ObjectReference Property Button3TopRight Auto
 
;Middle Buttons
ObjectReference Property Button4MiddleLeft Auto
ObjectReference Property Button5MiddleCenter Auto
ObjectReference Property Button6MiddleRight Auto
 
;Bottom Buttons
ObjectReference Property Button7BottomLeft Auto
ObjectReference Property Button8BottomCenter Auto
ObjectReference Property Button9BottomRight Auto
 
;Top Buttons GlobalVariable
GlobalVariable Property Button1TopLeftGBLVAR Auto
{Button GlobalVariables MUST be scripted on all buttons! OnActivate(MyButton) GlobalVariableName.SetValue(1)}
GlobalVariable Property Button2TopCenterGBLVAR Auto
GlobalVariable Property Button3TopRightGBLVAR Auto
 
;Middle Buttons GlobalVariable
GlobalVariable Property Button4MiddleLeftGBLVAR Auto
GlobalVariable Property Button5MiddleCenterGBLVAR Auto
GlobalVariable Property Button6MiddleRightGBLVAR Auto
 
;Bottom Buttons GlobalVariable
GlobalVariable Property Button7BottomLeftGBLVAR Auto
GlobalVariable Property Button8BottomCenterGBLVAR Auto
GlobalVariable Property Button9BottomRightGBLVAR Auto
 
ObjectReference Property Light01 Auto
{A light in front of each button to let the player know what button they have selected already.}
ObjectReference Property Light02 Auto
ObjectReference Property Light03 Auto
ObjectReference Property Light04 Auto
ObjectReference Property Light05 Auto
ObjectReference Property Light06 Auto
ObjectReference Property Light07 Auto
ObjectReference Property Light08 Auto
ObjectReference Property Light09 Auto
 
ObjectReference Property HintObject01 Auto
{Gives the player a hint for the button combo required. Best when placed AWAY from the Main buttons. This is NOT necessary to have, however since the button combos are randomly generated each time this is recommended!}
ObjectReference Property HintObject02 Auto
ObjectReference Property HintObject03 Auto
ObjectReference Property HintObject04 Auto
ObjectReference Property HintObject05 Auto
ObjectReference Property HintObject06 Auto
ObjectReference Property HintObject07 Auto
ObjectReference Property HintObject08 Auto
ObjectReference Property HintObject09 Auto
 
int MyRunCheck1
int MyRunCheck2
int MyRunCheck3
 
Bool RandNum01
Bool RandNum02
Bool RandNum03
Bool RandNum04
Bool RandNum05
Bool RandNum06
Bool RandNum07
Bool RandNum08
Bool RandNum09
 
int CorrectAttempt
int MyRandNum1
int MyRandNum2
int MyRandNum3
int WrongAttemptCnt
;How many times has the Player choosen the wrong button?

Bool Property ItemIsLocked Auto
{Is your item that you want to "unlock" a gate, door, or chest and is locked? If so choose this!
Only ONE of the following should be checked:
IsLocked
IsEnabled
ShouldSlide}

Bool Property DisableMyItem Auto
{If your item needs to be disabled choose this.
Only ONE of the following should be checked:
IsLocked
IsEnabled
ShouldSlide}

Bool Property ItemShouldSlide Auto
{If you want your item to open by sliding Up, choose this
Only ONE of the following should be checked:
IsLocked
IsEnabled
ShouldSlide}

Bool SlidingFunction
;This is not a visible function

Bool Property SlideUp Auto
{Should MyItem Slide Up?
WARNING: Only ONE slide direction should be selected!!!
Ensure that there is atleast DOUBLE the height on MyItem above its original location. This script will move it TWO TIMES IT's HEIGHT}

Bool Property SlideDown Auto
{Should MyItem Slide Down?
WARNING: Only ONE slide direction should be selected!!!
Ensure that there is atleast DOUBLE the height on MyItem below its original location. This script will move it TWO TIMES IT's HEIGHT}

Bool Property SlideLeft Auto
{Should MyItem Slide Left?
WARNING: Only ONE slide direction should be selected!!!
Ensure that there is atleast DOUBLE the space of left on MyItem above its original location. This script will move it TWO TIMES IT's LENGTH}

Bool Property SlideRight Auto
{Should MyItem Slide Right?
WARNING: Only ONE slide direction should be selected!!!
Ensure that there is atleast DOUBLE the space of right on MyItem above its original location. This script will move it TWO TIMES IT's LENGTH}

Float afX
;{Position along the X axis (Absolute world coordinates)}
Float afY
;{Position along the Y axis (Absolute world coordinates)}
Float afZ
;{Position along the Z axis (Absolute world coordinates)}
Float afAngleX
;{Destination X Angle (Absolute world rotation).}
Float afAngleY
;{Destination Y Angle (Absolute world rotation) (rarely used).}
Float afAngleZ
;{Destination Z Angle (Absolute world rotation).}
Float Property afSpeed Auto
{Movement Speed. Units per Second, start at 50 or 100 and work up.}
Float Property afMaxRotationSpeed Auto
{Maximum rotation Speed (default is 0 to mean "don't clamp the rotation speed") - Negative values cause unpredictable rotation.}

Spell Property WrongAttemptSpell Auto
{The spell to cast at the player after the Wrong Attempts}

ObjectReference Property SpellSource Auto
{The Source that will cast the Spell}

ObjectReference Property MyItemDustREF Auto
Sound Property MyItemSlideSound Auto
{What sound will be used for MyItem slide?}

Float MyItemLength
Float MyItemHeight
Float MyItemPosX
Float MyItemPosY
Float MyItemPosZ

Event OnInit()
    RegisterForSingleUpdate(5.0)
EndEvent
 
Auto State Initialize
    Event OnInit()
                ;http://www.creationkit.com/GetHeight_-_ObjectReference
                ;http://www.creationkit.com/GetLength_-_ObjectReference
                ;http://www.creationkit.com/ObjectReference_Script
        MyItemHeight = MyItem.GetHeight()
        MyItemLength = MyItem.GetLength()
        MyItemPosX = MyItem.GetPositionX()
        MyItemPosY = MyItem.GetPositionY()
        MyItemPosZ = MyItem.GetPositionZ()
        afX = MyItemPosX
        afY = MyItemPosY
        afZ = MyItemPosZ
        
        afAngleX = (MyItem.GetLength() * 2)
        afAngleY = (MyItem.GetLength() * 2) ;Rarely Used, kept here for reference
        afAngleZ = (MyItem.GetLength() * 2)
        
        
        ;Randomize and Select 3 numbers for the button combo
        if MyRunCheck1 == 0
            MyRandNum1 = RandomInt(1, 9)
            if MyRandNum1 == 9
                RandNum09 = True
            Elseif MyRandNum1 == 8
                RandNum08 = True
            Elseif MyRandNum1 == 7
                RandNum07 = True
            Elseif MyRandNum1 == 6
                RandNum06 = True
            Elseif MyRandNum1 == 5
                RandNum05 == True
            Elseif MyRandNum1 == 4
                RandNum04 == True
            Elseif MyRandNum1 == 3
                RandNum03 == True
            Elseif MyRandNum1 == 2
                RandNum02 == True
            Elseif MyRandNum1 == 1
                RandNum01 == True
            Endif
            Notification("My 1st Number Picked is: " + MyRandNum1)
            MyRunCheck1 + 1
        Endif
              
        if MyRunCheck2 == 0
            MyRandNum2 = MyRandNum1                
            While MyRandNum2 == MyRandNum1
                MyRandNum2 = RandomInt(1, 9)    
            EndWhile
                      
            if MyRandNum2 == 9
                RandNum09 = True
            Elseif MyRandNum2 == 8
                RandNum08 = True
            Elseif MyRandNum2 == 7
                RandNum07 = True
            Elseif MyRandNum2 == 6
                RandNum06 = True
            Elseif MyRandNum2 == 5
                RandNum05 == True
            Elseif MyRandNum2 == 4
                RandNum04 == True
            Elseif MyRandNum2 == 3
                RandNum03 == True
            Elseif MyRandNum2 == 2
                RandNum02 == True
            Elseif MyRandNum2 == 1
                RandNum01 == True
            Endif
            Notification("My 2nd Number Picked is: " + MyRandNum2)
            MyRunCheck2 + 1
        Endif

        if MyRunCheck3 == 0
            MyRandNum3 = MyRandNum2
            While (MyRandNum3 == MyRandNum2) || (MyRandNum3 == MyRandNum1)
                MyRandNum3 = RandomInt(1, 9)
            EndWhile
            if MyRandNum3 == 9
                RandNum09 = True
            Elseif MyRandNum3 == 8
                RandNum08 = True
            Elseif MyRandNum3 == 7
                RandNum07 = True
            Elseif MyRandNum3 == 6
                RandNum06 = True
            Elseif MyRandNum3 == 5
                RandNum05 == True
            Elseif MyRandNum3 == 4
                RandNum04 == True
            Elseif MyRandNum3 == 3
                RandNum03 == True
            Elseif MyRandNum3 == 2
                RandNum02 == True
            Elseif MyRandNum3 == 1
                RandNum01 == True
            Endif
            Notification("My 3rd Number Picked is: " + MyRandNum3)
            MyRunCheck3 + 1
        Endif

        if RandNum01 == True
            HintObject01.Enable()
        Endif

        if RandNum02 == True
            HintObject02.Enable()
        Endif

        if RandNum03 == True
            HintObject03.Enable()
        Endif

        if RandNum04 == True
            HintObject04.Enable()
        Endif

        if RandNum05 == True
            HintObject05.Enable()
        Endif

        if RandNum06 == True
            HintObject06.Enable()
        Endif

        if RandNum07 == True
            HintObject07.Enable()
        Endif

        if RandNum08 == True
            HintObject08.Enable()
        Endif

        if RandNum09 == True
            HintObject09.Enable()
        Endif

        Wait(3.0)
        ;Give 3 seconds to ensure that all HintObjects and other stuff has been completed.

        GoToState("Waiting")

    EndEvent
EndState
 
State Waiting
    Event OnActivate(ObjectReference akActivator) ;OnUpdate()
        if akActivator = GetPlayer()
            ;Combo Buttons stuff here
            ;Button1TopLeftGBLVAR
            ;Button2TopCenterGBLVAR
            ;Button3TopRightGBLVAR
            ;Button4MiddleLeftGBLVAR
            ;Button5MiddleCenterGBLVAR
            ;Button6MiddleRightGBLVAR
            ;Button7BottomLeftGBLVAR
            ;Button8BottomCenterGBLVAR
            ;Button9BottomRightGBLVAR
            ;Button Locations
            ;123
            ;456
            ;789
            if RandNum09 == True && Button9BottomRightGBLVAR.GetValue() == 1
                Light09.Enable()
                CorrectAttempt + 1
            Elseif RandNum09 == False && Button9BottomRightGBLVAR.GetValue() == 1
                WrongAttemptCnt + 1
            Endif

            if RandNum08 == True  && Button8BottomCenterGBLVAR.GetValue() == 1
                Light08.Enable()
                CorrectAttempt + 1
            Elseif RandNum08 == False && Button8BottomCenterGBLVAR.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum07 == True && Button7BottomLeftGBLVAR.GetValue() == 1
                Light07.Enable()
                CorrectAttempt + 1
            Elseif RandNum07 == False && Button7BottomLeftGBLVAR.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum06 == True && Button6MiddleRightGBLVar.GetValue() == 1
                Light06.Enable()
                CorrectAttempt + 1
            Elseif    RandNum06 == False && Button6MiddleRightGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum05 == True && Button5MiddleCenterGBLVar.GetValue() == 1
                Light05.Enable()
                CorrectAttempt + 1
            Elseif    RandNum05 == False && Button5MiddleCenterGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum04 == True && Button4MiddleLeftGBLVar.GetValue() == 1
                Light04.Enable()
                CorrectAttempt + 1
            Elseif RandNum04 == False && Button4MiddleLeftGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum03 == True && Button3TopRightGBLVar.GetValue() == 1
                Light03.Enable()
                CorrectAttempt + 1
            Elseif RandNum03 == False && Button3TopRightGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum02 == True && Button2TopCenterGBLVar.GetValue() == 1
                Light02.Enable()
                CorrectAttempt + 1
            Elseif RandNum02 == False && Button2TopCenterGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif
            
            if RandNum01 == True && Button1TopLeftGBLVar.GetValue() == 1
                Light01.Enable()
                CorrectAttempt + 1
            Elseif RandNum01 == False && Button1TopLeftGBLVar.GetValue() == 1
                WrongAttemptCnt + 1
            Endif

            ;Wrong Attempt Stuff
            if WrongAttemptCnt == 3
                WrongAttemptSpell.Cast(SpellSource,GetPlayer())
                WrongAttemptCnt = 0
            Endif
            
            ;Correct Attempt (Successful Lock Number Choosen)
            if CorrectAttempt == 3
                if ItemIsLocked == True
                    MyItem.Lock(False)
                Elseif DisableMyItem == True
                    MyItem.Disable()
                Else ItemShouldSlide == True
                    ;Do Stuff
                    ;Create new Event for SlideFunction
                    GoToState("ShouldSlideFunction")
                Endif
            Endif
        Endif
    EndEvent
EndState

State ShouldSlideFunction
    Event OnBeginState() ;CWCatapultWeaponFireSCRIPT.psc for example of OnBeginState
        If SlideUp == True
                ;Try to automate the entire movement of all directions. Try not to have anything for the user to set except "afSpeed" and "afMaxRotationSpeed"
            MyItem.TranslateTo(afX, afY, afZ, afAngleX, afAngleY, afAngleZ, afSpeed, afMaxRotationSpeed)
            MyItemDustREF.Enable()
            MyItemSlideSound.Play(MyItem)
            
        Elseif SlideDown == True
            ;Do Stuff
        Elseif SlideLeft == True
            ;Do Stuff
        Elseif SlideRight == True
            ;Do Stuff
        Else MessageBox("Error: Something went wrong, please check to ensure that only ONE Slide Direction was choosen in aaDSoSRandomComboLock script.")
        Endif
    EndEvent
EndState

;All possible slide direction combonations that could be selected, only ONE option should be selected.
;How to check for every option below?
;{SlideUp,SlideDown}
;{SlideUp,SlideLeft}
;{SlideUp,SlideRight}
;{SlideDown,SlideUp}
;{SlideDown,SlideLeft}
;{SlideDown,SlideRight}
;{SlideLeft,SlideUp}
;{SlideLeft,SlideDown}
;{SlideLeft,SlideRight}
;{SlideRight,SlideUp}
;{SlideRight,SlideDown}
;{SlideRight,SlideLeft}

;{SlideUp,SlideDown,SlideLeft}
;{SlideUp,SlideDown,SlideRight}
;{SlideUp,SlideLeft,SlideDown}
;{SlideUp,SlideLeft,SlideRight}
;{SlideUp,SlideRight,SlideDown}
;{SlideUp,SlideRight,SlideLeft}
;{SlideDown,SlideUp,SlideLeft}
;{SlideDown,SlideUp,SlideRight}
;{SlideDown,SlideLeft,SlideUp}
;{SlideDown,SlideLeft,SlideRight}
;{SlideDown,SlideRight,SlideUp}
;{SlideDown,SlideRight,SlideLeft}
;{SlideLeft,SlideUp,SlideDown}
;{SlideLeft,SlideUp,SlideRight}
;{SlideLeft,SlideDown,SlideUp}
;{SlideLeft,SlideDown,SlideRight}
;{SlideLeft,SlideRight,SlideUp}
;{SlideLeft,SlideRight,SlideDown}
;{SlideRight,SlideUp,SlideDown}
;{SlideRight,SlideUp,SlideLeft}
;{SlideRight,SlideDown,SlideUp}
;{SlideRight,SlideDown,SlideLeft}
;{SlideRight,SlideLeft,SlideUp}
;{SlideRight,SlideLeft,SlideDown}

;{SlideUp,SlideDown,SlideLeft,SlideRight}
;{SlideUp,SlideDown,SlideRight,SlideLeft}
;{SlideUp,SlideLeft,SlideDown,SlideRight}
;{SlideUp,SlideLeft,SlideRight,SlideDown}
;{SlideUp,SlideRight,SlideDown,SlideLeft}
;{SlideUp,SlideRight,SlideLeft,SlideDown}
;{SlideDown,SlideUp,SlideLeft,SlideRight}
;{SlideDown,SlideUp,SlideRight,SlideLeft}
;{SlideDown,SlideLeft,SlideUp,SlideRight}
;{SlideDown,SlideLeft,SlideRight,SlideUp}
;{SlideDown,SlideRight,SlideUp,SlideLeft}
;{SlideDown,SlideRight,SlideLeft,SlideUp}
;{SlideLeft,SlideUp,SlideDown,SlideRight}
;{SlideLeft,SlideUp,SlideRight,SlideDown}
;{SlideLeft,SlideDown,SlideUp,SlideRight}
;{SlideLeft,SlideDown,SlideRight,SlideUp}
;{SlideLeft,SlideRight,SlideUp,SlideDown}
;{SlideLeft,SlideRight,SlideDown,SlideUp}
;{SlideRight,SlideUp,SlideDown,SlideLeft}
;{SlideRight,SlideUp,SlideLeft,SlideDown}
;{SlideRight,SlideDown,SlideUp,SlideLeft}
;{SlideRight,SlideDown,SlideLeft,SlideUp}
;{SlideRight,SlideLeft,SlideUp,SlideDown}
;{SlideRight,SlideLeft,SlideDown,SlideUp}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...