OnActivate

Post » Tue Sep 13, 2011 9:50 pm

I have this simple script attached to a container but it doesnt work.

if ( onActivate )	set timer to ( timer + getsecondspassed )endifif ( timer > 2 )	messagebox "activate"	activateendif


Whats wrong with it?
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am

Post » Wed Sep 14, 2011 3:25 am

I have this simple script attached to a container but it doesnt work.

if ( onActivate )	set timer to ( timer + getsecondspassed )endifif ( timer > 2 )	messagebox "activate"	activateendif


Whats wrong with it?


OnActivate returns true only for one frame for each activation of the object. The line set timer to ( timer + getsecondspassed ) therefore only gets executed once, so the variable timer will not reach 2 unless you activate the object many times, repeatedly.

Here's a fixed version:

short statefloat timerif ( MenuMode == 1 )	Returnendifif ( OnActivate == 1 )	set state to 1	Returnendifif ( state == 0 )	Returnendifset timer to ( timer + getsecondspassed )if ( timer >= 2 )	MessageBox, "Activate"	set timer to 0	set state to 0endif

User avatar
Ownie Zuliana
 
Posts: 3375
Joined: Thu Jun 15, 2006 4:31 am

Post » Tue Sep 13, 2011 12:40 pm

Thanks
User avatar
BrEezy Baby
 
Posts: 3478
Joined: Sun Mar 11, 2007 4:22 am


Return to III - Morrowind