Jump to content

Need a script for closing a door then locking (req premade key)


RedNinja029

Recommended Posts

Asking questions line for line is a great idea. I suppose I sort of assumed that to a degree it was speaking for itself, so sorry for that. It's been a really long time since I first started the basics of scripting, even if I'm still a bit new to this engine in particular.

 

First, the == thing is because in this programming language, that's just 'the way it is'. Some languages use = for stuff, but in this one, we don't. Have a look at this page:

https://geckwiki.com/index.php/NVSE_Expressions

It's called NVSE expressions because it encompasses all the expressions NVSE can handle, but many of them were already there in vanilla.

scn BunkerDoorScript

; these first two things are variables. They don't do anything, 
; but they can have values assigned to them based on events or 
; other values, and then we can check them and tell the engine
; to perform (or not perform) operations contingent on what the
; results of the check are. When you put them here at the 
; beginning of a script like this, it's called 'declaring' a 
; variable.  It involves stating the type of variable and then
; the name you wish to give it.

int      DoTimer  ; this is a variable I'll use to tell the game when to run the timer.  It's more like a 'switch' than a timer, but DoTimer itself is not a
                  ; switch nor is the Timer variable a timer.  They are just numbers that we use to get the effect we want.
float    Timer    ; this is not a timer, but if manipulated correctly, using GetSecondsPassed, we are 'making' one.

Begin GameMode  ; GameMode blocks run all the time and track time, unlock other blocktypes.
    If DoTimer == 0 ; 1-Firstly why == as opposed to = ? 2- DoTimer is resetting the Timer to 0 ---- #1 is explained above.  #2 DoTimer in my script acts more like a switch.
                                                                                                                              ; When it's set to 0, we are checking the value
                                                                                                                              ; of GetOpenState, and nothing else.
        If GetOpenState == 1 ;If the Door becomes Open then...      ---- This script is always waiting for the game to find the door open.  So I think you got this one.
            Set DoTimer to 1 ;Set The Counter Timer to 1            ---- We're just setting our 'switch' to the setting of 1, which in the next line tells the game 
                                                                       ; to ready the timer, or more accurately, it assigns our variable called Timer a value of 8.
        EndIf                                                       ---- This EndIf is for the GetOpenState line.
    ElseIf DoTimer == 1 ;Not sure how to use ElseIf or when it should be used ;When it becomes 1 do the following  ---- It's used where you'd normally put EndIf, and it
                                                                                                                      ; means, 'If the previous check did not return true,
                                                                                                                      ; do or check this upcoming stuff.'
        Set Timer to 8 ;Is this Set Timer To 8 the threshold/limit for the timer? ---- This is what the timer will count down from.  It's not really a timer, just a variable.
        Set DoTimer to 2 ;This baffles me as I can't grasp how this DoTimer is working at this point    ---- We are now setting our switch to 2, and only when
                                                                                                           ; our switch is at 2 does our timer actually start
                                                                                                           ; working, as per the next line.
    ElseIf DoTimer == 2
        Set Timer to Timer - GetSecondsPassed ; Would - be counting down and + be counting up? ---- Indeed.  You got this one.  We would probably have set Timer to 0 instead 
                                                                                                  ; of 8 if we wanted to count up, but every situation is different.
        If Timer <= 0 ; This means if the timer is equal or less than 0?  ---- Correct.
            SetOpenState 0
            If GetOpenState == 3 ; Same as before not sure difference between = and ==
                Set DoTimer to 0 ; Does this mean the timer has stopped running    ---- This actually is the switch 'setting' that tells our timer to stop running.
            EndIf
        EndIf ;Not sure why there are 3 EndIfs as opposedto 1? ---- Cos I nested several If statements together, and each one needs to be 'ended'.  They all line up if you look.
    EndIf
End
; To recap what DoTimer is, I have made it a 'switch' (my term, not standard usage) with three settings.
; Setting 0 - makes the script do nothing but wait for the door to be found open. If found open, it sets our switch to 1.
; Setting 1 - Any time the game finds our switch at 1, it sets the timer to 8 (or 5, as you now have it) and sets the switch to 2.
; Setting 2 - Whenever the game finds our switch at 2, it counts down the Timer variable based on seconds, does stuff when the timer passes 0, and sets our
;             switch back to 0, waiting for the door to be found open once again.

Look at this page for an explanation of variables. The only one missing (I think) is the array variable, which is like a form list but as a variable. You probably won't need it for a bit.

https://geckwiki.com/index.php/Category:Variables

 

Sorry, spent so long on the script questions that I forgot there was other stuff in your post.

 

No bother at-all, really. I like helping people and I think my brain processes it like a puzzle, and I of course love puzzles. If you've ever read Sherlock Holmes (read, not watched), it's not unlike what drives him, though I'm obviously doing work with a higher purpose improving computer games and all.

 

This stuff will not cause significant trouble because the scripts don't even run to my knowledge unless you're in the same cell. At least, they don't run at the same processing level, because the variables don't update. Your worst case would be slowdown within your bunker, but it would take a whole lot to do that. Quest scripts on the other hand run all the time unless turned off, but the upside is that they're very customisable. And even then, scripts like that usually process every 5 seconds, and usually don't cause much trouble in that case. It's still good modding etiquette to have as few scripts running as possible.

 

Save game bloat is from having interacted with a lot of stuff. When the cells are purged, it relieves a lot of that, which is why PCB mods are popular. However, they're dangerous to scripts and shouldn't be used. There are some .ini settings you can set to handle it better.

 

Scripts do contribute to this problem, but not usually much. They can add up, though, which is why you should try to minimise which ones are running when possible.

 

 

As a result of variables not updating in fact, I've been trying to make a nice script that handles closing the doors once the player leaves the cell, and it's not working yet, at least not the way I'd like. I would ideally have one script that can be put on all the doors without changing anything. I have some ideas but nothing concrete yet.

 

---------------------------------------------------------

 

Edit: Hadn't noticed your update in that comment. Seems you're getting on well. Thrilled to hear it. From the sound of it, I don't think you needed me again just yet, but let me know how you fare with the lights and all that.

 

What you need is another script entirely if you want the automatic doors to close when the player is not in the cell. It seems, which is a revelation to me, that GameMode blocks don't run in an Object script when you're not in the cell with the object, which actually makes this significantly better for CPU load than I would have thought. I think a lot of the PSAs about this are assuming it's as it was in Oblivion, where I assume it was still a problem. Quest scripts will run regardless of the cell you're in, which is good for control, but I think this script you already have here may be the exact thing you want, now that I realise it doesn't (seem to) run if you leave the cell. Just needs to be complemented by another one to close the doors if you want that.

 

Good thinking about the keycard doors and the companions. And definitely add as much sound work as you can do; it will improve the experience far more than non-audio people ever seem to realise.

Edited by EPDGaffney
Link to comment
Share on other sites

Just popped on took the day off today, ill have a quick read through now, I'll edit this post shortly. Im having an issue with a mod at moment and couldnt start the game so trying a fresh install

Edited by RedNinja029
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...