Guest Morlok Posted August 29, 2003 Share Posted August 29, 2003 hi, I just started creating some plugins and have one problem I can't solve: I want to write a script for a door that locks itself after a few seconds when opened. All I have is: if (OnActivate)Activate here should be the part that makes the door wait some seconds after opened. but how do I do this?? then the door locks itself "nameofdoor"->Lock 100endif thanks for your help, morlok ah, by the way...sorry when I made too much mistakes, english is a foreign language foro me and I am not used to speak it often since I left school... Link to comment Share on other sites More sharing options...
DM Posted August 29, 2003 Share Posted August 29, 2003 The scripting in morrowind runs off a true or false system. The only real way to tell time is the GetSecondsPassed command. Begin your_script_doorlock short locked float timer if ( menumode == 1 ) return endif if ( locked == 1 ) if ( timer > 10 ) ;set timer to whatever you want "youdoorID"-> Lock 100 ;I'm not sure of the proper command here, but that should work set timer to 0 set locked to 0 endif endif if ( OnActivate == 1 ) if ( locked != 1 ) set timer to ( timer + GetSecondPassed ) set locked to 1 endif return endif End I wrote that off the top of my head, so no guaruntees but it's a start. :) Link to comment Share on other sites More sharing options...
Switch Posted August 29, 2003 Share Posted August 29, 2003 u wrote THAT off the top of ur head... heh programmers... :blink: Link to comment Share on other sites More sharing options...
DM Posted August 29, 2003 Share Posted August 29, 2003 Not really a programmer. I've been using the CS for well over a year now, and have tought myself (yes, tought myself, I CANNOT stand tuts, they confuse me) most aspects relating to it. Link to comment Share on other sites More sharing options...
Morlok Posted August 30, 2003 Share Posted August 30, 2003 hey, DM, thanks for your fast reply, I'll try this when I've got some time. Link to comment Share on other sites More sharing options...
breck Posted August 31, 2003 Share Posted August 31, 2003 another way to time stuff is with a long variable. Use somthig like this; long timer if ( timer =< #some value ) set timer to ( timer + 1 ) returnendif "door ID"-> lockstopscript end you might have to tweeck this a littel bit but I've used ones like it to time stuff.note that the script runs every frame so the timer value grows fast, set the # to somthig high. longs can be over 2 billion though so you shouldent have a problem geting the time write. Link to comment Share on other sites More sharing options...
Morlok Posted September 1, 2003 Share Posted September 1, 2003 hey, thanks for your help DM, you showed me the right way but it still took me some time to make this working. It is not perfect, but this is my result and in most parts it works. Begin door_lock short lockedfloat timer if (menumode==1)returnendif if (timer==0)set locked to 2set timer to 1endif if (locked ==1) if (timer >5) "door_ID"->Lock 100 set timer to 0 set locked to 0 else set locked to 0 return endifendif if (OnActivate==1)Activateset locked to 0returnendif End I guess I made it much too complicated but I´m happy that I got this working. There is just one thing I would like to add: can I make the door close as slowly as it opens? Right now you don´t see the door closeing, it just "slams". Any ideas? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.