Jump to content

need help with scripting


Guest Morlok

Recommended Posts

Guest Morlok

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 100

endif

 

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

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

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 )

return

endif

 

"door ID"-> lock

stopscript

 

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

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 locked

float timer

 

if (menumode==1)

return

endif

 

if (timer==0)

set locked to 2

set timer to 1

endif

 

if (locked ==1)

if (timer >5)

"door_ID"->Lock 100

set timer to 0

set locked to 0 else

set locked to 0

return

endif

endif

 

if (OnActivate==1)

Activate

set locked to 0

return

endif

 

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

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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