Jump to content

Scriptng Question How to set a timer


dedmax

Recommended Posts

I made a spell that when hits the target remote activates a chest i have placed in my cell at which time i place objects into the chest.

The script then calls for the chest to removeallitems to the target.

The chest opens fine and i place items inside it but i have to hit the target again to have the objects remove to target.i would like to set a time delay on the remove call to allow the objects i placed into the chest to become true(assuming thats the problem).Ive consulted the wiki which is why im now having to ask this community for enlightenment.Several of my spell ideas are on hold untill i can understand timers so any input on the basics of timers would be appreciated.

Link to comment
Share on other sites

Does not seem to be a timing issue. But anyway . . .

 

The most common timer is a count-down timer that uses the GetSecondsPasssed function:

1- Some event sets the timer to its initial value, say, 3 (meaning 3 real time seconds)

2- Every frame, a gamemode block subtracts GetSecondsPasssed from the timer

3- When the timer gets negative, the elapsed time has passed and you do your stuff

 

Simple sample code

Float xTimer
Begin onactivate
Set xTimer to 3
End
Begin gamemode
Set xTimer to xTimer - GetSecondsPasssed
If xTimer <= 0
	[delayed code here]
Endif
End

You may also set a count-up timer if you need to run code at several different moments after an original event.

And, I suppose, there must be many other less common variations.

Link to comment
Share on other sites

Thanx QQuix This should be very helpful to me.

 

If i put something into the chest prior to using the spell

 

then activate the spell and add an item at that time only the first item will transfer .

I will try the code you provinded thanx again

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...