Rumpiraten Posted December 2, 2012 Share Posted December 2, 2012 Hey there fellow modders.. I've just recently started messing around in the G.E.C.K, trying to make a hideout for my evil slaver character :devil:I've reached the point where I'm pretty much done, all I need now is some finishing touches.One of which, is the automatic closing of this hidden door I've put in, and for the life of me I can't get that damn thing working :D I found this script on Bethesda's G.E.C.K tutorial pages and slapped it on my hidden door, but as far as I can tell, it does absolutely nothing. Scriptname AutoClosingDoor float doorTimer short closeDoor Begin GameMode if closeDoor == 1 if doorTimer > 0 set doorTimer to doorTimer - getSecondsPassed elseif GetOpenState == 1 ; if the door is still open SetOpenState 0 ; close the door set closeDoor to 0 endif endif End Begin OnActivate if GetOpenState == 3 ; if the door is closed if IsActionRef Player == 0 ; if it should work for the player remove this... set doorTimer to 5 set closeDoor to 1 endif ; ...and this endif Activate End I've made one or two very basic "Use this switch/terminal to open/lock/unlock, this and that door", but the above script is just way too complicated to wrap my head around :DBasically I just want my door to close again, 3-5 seconds after I've opened it, and I thought Beth's "useful" script would do that.I'm kinda figuring it's because it's a switch operated door, but I'm not sure, so any help would be greatly appreciated :D Link to comment Share on other sites More sharing options...
Xaranth Posted December 2, 2012 Share Posted December 2, 2012 Hey there fellow modders.. I've just recently started messing around in the G.E.C.K, trying to make a hideout for my evil slaver character :devil:I've reached the point where I'm pretty much done, all I need now is some finishing touches.One of which, is the automatic closing of this hidden door I've put in, and for the life of me I can't get that damn thing working :D I found this script on Bethesda's G.E.C.K tutorial pages and slapped it on my hidden door, but as far as I can tell, it does absolutely nothing. Scriptname AutoClosingDoor float doorTimer short closeDoor Begin GameMode if closeDoor == 1 if doorTimer > 0 set doorTimer to doorTimer - getSecondsPassed elseif GetOpenState == 1 ; if the door is still open SetOpenState 0 ; close the door set closeDoor to 0 endif endif End Begin OnActivate if GetOpenState == 3 ; if the door is closed if IsActionRef Player == 0 ; if it should work for the player remove this... set doorTimer to 5 set closeDoor to 1 endif ; ...and this endif Activate End I've made one or two very basic "Use this switch/terminal to open/lock/unlock, this and that door", but the above script is just way too complicated to wrap my head around :DBasically I just want my door to close again, 3-5 seconds after I've opened it, and I thought Beth's "useful" script would do that.I'm kinda figuring it's because it's a switch operated door, but I'm not sure, so any help would be greatly appreciated :D As per the comments, remove the lines "if IsActionRef Player == 0" and its paired endIf. That SHOULD make it work as you wish it to. As it's set, the door'll only shut automatically if someone other than the player opens it. Also report back, I'm interested to see if it works. If not, I bet I can come up with something. Link to comment Share on other sites More sharing options...
Rumpiraten Posted December 2, 2012 Author Share Posted December 2, 2012 Speedy reply there mate, thanks :) I've edited the script so that it looks like this Scriptname 00AutoClosingDoor float doorTimer short closeDoor Begin GameMode if closeDoor == 1 if doorTimer > 0 set doorTimer to doorTimer - getSecondsPassed elseif GetOpenState == 1 ; if the door is still open SetOpenState 0 ; close the door set closeDoor to 0 endif endif End Begin OnActivate if GetOpenState == 3 ; if the door is closed set doorTimer to 5 set closeDoor to 1 endif Activate End But the problem remains and the door stays open o_O Link to comment Share on other sites More sharing options...
Xaranth Posted December 2, 2012 Share Posted December 2, 2012 (edited) Speedy reply there mate, thanks :) I've edited the script so that it looks like this But the problem remains and the door stays open o_O Okay then. Try this: scn DummyDoorAutoClose ref rMe float fTick Begin onLoad Set rMe to GetSelf end Begin GameMode if rMe.GetOpenState Set fTick to fTick + GetSecondsPassed if fTick > 5 Set fTick to 0 rMe.SetOpenState 0 endIf endIf end It's rather... blunter, than the example script, but it works, at least in my testing. Edit: Also, be aware that GetSelf can be finicky. If you're instantiating the door at runtime, it will likely bollix up. In that case, use implicit referencing. Edited December 2, 2012 by Xaranth Link to comment Share on other sites More sharing options...
Rumpiraten Posted December 2, 2012 Author Share Posted December 2, 2012 Hmm still nothing... If you're instantiating the door at runtime, it will likely bollix up. In that case, use implicit referencing What do you mean by that exactly, bear in mind that I'm green as a cucumber lol :tongue: Link to comment Share on other sites More sharing options...
Xaranth Posted December 2, 2012 Share Posted December 2, 2012 Hmm still nothing... If you're instantiating the door at runtime, it will likely bollix up. In that case, use implicit referencing What do you mean by that exactly, bear in mind that I'm green as a cucumber lol :tongue: Basically, if the door is created via a script while the game is running, take out the onload block, and remove all the rMe. prefixes. Also, the script needs to be an OBJECT type script: and attached to the door: Not the switch that you're using to open the door from elsewhere. You might also need to play with the fTick max value. Link to comment Share on other sites More sharing options...
Rumpiraten Posted December 2, 2012 Author Share Posted December 2, 2012 Ah I see, thanks for clearing that up. That part is not a problem though, as I don't have the game running while G.E.C.K'ing :)I checked to see if the script type was set to "Object" as I've had some trouble with that earlier on, but nope, it's an object script all right. And for the last part, you kinda beat me to it, cus I was wondering if I should add the door code to my switch script, but I guess that doesn't really make sense either :D I'm gonna try fiddling with the fTick value a bit, see if it makes any difference :) Link to comment Share on other sites More sharing options...
Xaranth Posted December 2, 2012 Share Posted December 2, 2012 Ah I see, thanks for clearing that up. That part is not a problem though, as I don't have the game running while G.E.C.K'ing :)I checked to see if the script type was set to "Object" as I've had some trouble with that earlier on, but nope, it's an object script all right. And for the last part, you kinda beat me to it, cus I was wondering if I should add the door code to my switch script, but I guess that doesn't really make sense either :D I'm gonna try fiddling with the fTick value a bit, see if it makes any difference :) No, what I mean by instantiating at runtime is using PlaceAtMe, AddItem, and other constructors (Including Levelled Lists) to 'create' objects in the game with some degree of dynamicism. In that case, GetSelf will do weird things to the game, and so should not be used, and implicit referencing syntax used instead. Actually, I probably should have used implicit referencing anyway, but I've got a bug about it. ALSO. If you're loading a save to test in the cell where the door is, it's probably not the SCRIPT that's broken. The save says the 3ddata's already loaded, so the onload block isn't triggering, and rMe is showing null. If that's the case, try leaving your cell and running around for awhile. If you go to 8-10 other locations, then return, it SHOULD clear the 3D Data and cause a reset. Or you could just try this: scn DummyDoorAutoClose float fTick Begin GameMode if GetOpenState Set fTick to fTick + GetSecondsPassed if fTick > 5 Set fTick to 0 SetOpenState 0 endIf endIf end Which just makes me squick, but that's a personal failing (I HATE implicit syntax). There's nothing WRONG with it, and obviously, if it works, it's probably better that way. Link to comment Share on other sites More sharing options...
Rumpiraten Posted December 2, 2012 Author Share Posted December 2, 2012 Hehe aaah... yeah okay, I think I know what you are getting at now :D But you're right, I'm loading a save where I'm already in the cell. I'm going to try an older save and/or running around a bit, and if that doesn't work, then ill give your last script a shot :) Link to comment Share on other sites More sharing options...
Rumpiraten Posted December 2, 2012 Author Share Posted December 2, 2012 Most excellent good sir, loading an older save did the trick :thumbsup:However, the door seems to be closing at semi random times from around 2 to 6 seconds? But thanks a lot for your help so far, that's one hurdle to cross of my list :D Now with the auto close in place, is it possible to get the light on my switch to match the state of the door?It already animates on activate, I'm just a sucker for details, and I would hate to see my door closed, while the light on the switch is green :) Link to comment Share on other sites More sharing options...
Recommended Posts