MenuMode & Timers

Post » Sun Dec 04, 2011 3:39 am

Evening, me again,

Am I right in thinking that you can't start a timer going whilst in a ShowMessage menu?

For some reason, the timer doesnt seem to start, so I tried splitting the script up into 3 parts, OnActivate, MenuMode and GameMode, didn't make much difference, so then I tried bundling it all into just OnActivate and GameMode, then setting an activation variable which is rings true during gameMode, starts the timer. Again, no joy. Is this ebcause the option of setting ActivateTimer runs at the same time as the option to check if its true or not?

Script below's a bit higgledypiggledy, any ideas? Thankos :)

scn TARDISbuttonPower SCRIPTshort Buttonshort timershort ActivateTimerbegin onActivate playerif getStage LCoG == 100	if tardispowermode == 0		ShowMessage TARDISpowerDown			endif	endifendbegin gameMode	set Button to GetButtonPressed	if ( Button == 0 ) 		set tardispowermode to 1		tardisheart.disable		tardisgroaning.enable		poweroutbeam.enable		consoleroomlight1.disable		consoleroomlight2.disable		consoleroomlight3.disable		consoleroomlight4.disable		PlaySound OBJTurretGeneratorDisable		PlaySound OBJSwitchButtonBPass		set ActivateTimer to 1		if ( Button == 1 ) 	endifif ActivateTimer == 1	if timer < 5      		set timer to timer + GetSecondsPassed  		 else     		showMessage TARDISpowerUp      		set timer to 0      		set tardispowermode to 0			tardisheart.enable			tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp   		endif	endifset ActivateTimer to 0endifend

User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Sun Dec 04, 2011 6:32 am

1. Indented your code correctly.
2. Removed the space in the script name.
3. Added 'Return' when button == 1
4. Added condition to code where you grab the button pressed. You don't want to do that ALL the time.
5. Your resetting ActivateTimer to zero every single time the script runs, so the timer would never get higher than 5 before its set to 0 and that section of code is never looked at again. So I moved it inside the IF condition instead.

scn TARDISbuttonPowerSCRIPTshort Buttonshort timershort ActivateTimershort myStatebegin onActivate player	if getStage LCoG == 100		if tardispowermode == 0			ShowMessage TARDISpowerDown			set myState to 1		endif		endifendbegin gameMode	if myState == 1			set Button to GetButtonPressed		if Button == 0			set tardispowermode to 1			tardisheart.disable			tardisgroaning.enable			poweroutbeam.enable			consoleroomlight1.disable			consoleroomlight2.disable			consoleroomlight3.disable			consoleroomlight4.disable			PlaySound OBJTurretGeneratorDisable			PlaySound OBJSwitchButtonBPass			set ActivateTimer to 1			set myState to 0		elseif Button == 1			set myState to 0			return		endif	endif	if ActivateTimer == 1		if timer < 5	      		set timer to timer + GetSecondsPassed		else	     		showMessage TARDISpowerUp	      		set timer to 0	      		set tardispowermode to 0			tardisheart.enable			tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp			set ActivateTimer to 0		endif	endifend

User avatar
Miss Hayley
 
Posts: 3414
Joined: Tue Jun 27, 2006 2:31 am

Post » Sun Dec 04, 2011 3:52 pm

1. Indented your code correctly.
2. Removed the space in the script name.
3. Added 'Return' when button == 1
4. Added condition to code where you grab the button pressed. You don't want to do that ALL the time.
5. Your resetting ActivateTimer to zero every single time the script runs, so the timer would never get higher than 5 before its set to 0 and that section of code is never looked at again. So I moved it inside the IF condition instead.

scn TARDISbuttonPowerSCRIPTshort Buttonshort timershort ActivateTimershort myStatebegin onActivate player	if getStage LCoG == 100		if tardispowermode == 0			ShowMessage TARDISpowerDown			set myState to 1		endif		endifendbegin gameMode	if myState == 1			set Button to GetButtonPressed		if Button == 0			set tardispowermode to 1			tardisheart.disable			tardisgroaning.enable			poweroutbeam.enable			consoleroomlight1.disable			consoleroomlight2.disable			consoleroomlight3.disable			consoleroomlight4.disable			PlaySound OBJTurretGeneratorDisable			PlaySound OBJSwitchButtonBPass			set ActivateTimer to 1			set myState to 0		elseif Button == 1			set myState to 0			return		endif	endif	if ActivateTimer == 1		if timer < 5	      		set timer to timer + GetSecondsPassed		else	     		showMessage TARDISpowerUp	      		set timer to 0	      		set tardispowermode to 0			tardisheart.enable			tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp			set ActivateTimer to 0		endif	endifend



Thanks Willie, once again, you've saved my bacon. Quick question, is the my State equivalent to a doOnce then? I completely see what you mean now, such a fool. it's funny how things become clear when the tiniest mistake's pointed out. Thanks buddy :)
User avatar
J.P loves
 
Posts: 3487
Joined: Thu Jun 21, 2007 9:03 am

Post » Sun Dec 04, 2011 1:30 am

'doOnce' is just a variable that is easy to spot as something that you will code to only perform one time.

'myState' is also just a variable, but I use this because it gets reset so you can 're-do' the section of code that is controlled by the variable. You 'could' use the variable 'doOnce' but it would be confusing since its really not a 'do it one time' controller variable.
User avatar
Philip Rua
 
Posts: 3348
Joined: Sun May 06, 2007 11:53 am

Post » Sun Dec 04, 2011 4:32 am

Hmm, Ive just got back from work and popped the code in, yet it still doesn't seem to be 'powering up' after 5 seconds. What could I have missed?
User avatar
Minako
 
Posts: 3379
Joined: Sun Mar 18, 2007 9:50 pm

Post » Sun Dec 04, 2011 2:28 pm

Does the first section 'activate' properly?
Also, make sure your using a clean save game. Scripts will run from whats in your saved game.

I would also change the timer to count down instead of count 'up'.

			set myState to 0			set timer to 5		elseif Button == 1			set myState to 0			return		endif	endif	if ActivateTimer == 1		if timer >= 0	      		set timer to timer - GetSecondsPassed		else	     		showMessage TARDISpowerUp'*delete      		set timer to 0	      		set tardispowermode to 0			tardisheart.enable			tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp			set ActivateTimer to 0		endif	endif

User avatar
Emily Martell
 
Posts: 3469
Joined: Sun Dec 03, 2006 7:41 am

Post » Sun Dec 04, 2011 2:41 pm

Does the first section 'activate' properly?
Also, make sure your using a clean save game. Scripts will run from whats in your saved game.

I would also change the timer to count down instead of count 'up'.

			set myState to 0			set timer to 5		elseif Button == 1			set myState to 0			return		endif	endif	if ActivateTimer == 1		if timer >= 0	      		set timer to timer - GetSecondsPassed		else	     		showMessage TARDISpowerUp'*delete      		set timer to 0	      		set tardispowermode to 0			tardisheart.enable			tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp			set ActivateTimer to 0		endif	endif



First section sure activates, aye. All the lights disable, the sounds play as planned etc. Just tried implementing your suggestion, and still nothing. It's either not running the timer, or not checking when the timer is over 5 seconds.
User avatar
c.o.s.m.o
 
Posts: 3419
Joined: Sat Aug 12, 2006 9:21 am

Post » Sun Dec 04, 2011 2:36 pm

Can you post the entire script as you have it saved now?

Also, what is this script attached to? Is it an object that might be getting 'disabled' which would cause the script to stop running.
User avatar
Ebony Lawson
 
Posts: 3504
Joined: Fri Feb 16, 2007 11:00 am

Post » Sun Dec 04, 2011 5:47 am

Can you post the entire script as you have it saved now?

Also, what is this script attached to? Is it an object that might be getting 'disabled' which would cause the script to stop running.


With pleasure

scn TARDISbuttonPowerSCRIPTshort Buttonshort timershort ActivateTimershort myStatebegin onactivate player	if getStage LCoG == 100		if tardispowermode == 0			ShowMessage TARDISpowerDown			set myState to 1		endif		endifendbegin gameMode	if myState == 1			set Button to GetButtonPressed		if Button == 0			set tardispowermode to 1			tardisheart.disable			;tardisgroaning.enable			poweroutbeam.enable			consoleroomlight1.disable			consoleroomlight2.disable			consoleroomlight3.disable			consoleroomlight4.disable			PlaySound OBJTurretGeneratorDisable			PlaySound OBJSwitchButtonBPass			set ActivateTimer to 1			set myState to 0			set timer to 5		elseif Button == 1			set myState to 0			return		endif	endif	if ActivateTimer == 1		if timer >= 0	      		set timer to timer - GetSecondsPassed		else	     		showMessage TARDISpowerUp	      		;set timer to 0	      		set tardispowermode to 0			tardisheart.enable			;tardisgroaning.disable			poweroutbeam.disable			consoleroomlight1.enable			consoleroomlight2.enable			consoleroomlight3.enable			consoleroomlight4.enable			PlaySound AMBElevatorMonumentPowerUp			set ActivateTimer to 0		endif	endifend


The script is applied to an Activator (a button) which is a persistent ref which is never disabled via any other script.
User avatar
Skivs
 
Posts: 3550
Joined: Sat Dec 01, 2007 10:06 pm

Post » Sun Dec 04, 2011 11:00 am

It should work.

Make sure you are using a clean game save (a save game that was never 'saved' when your mod was activated.)
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Post » Sun Dec 04, 2011 1:00 pm

It should work.

Make sure you are using a clean game save (a save game that was never 'saved' when your mod was activated.)


Yup, been using a clean save and still nothing. I even just set another button to display the ActivateTimer variable from the script to ensure it IS setting to 1, and true enough, it's setting to 1.

I'm really puzzled with this one.
User avatar
Vivien
 
Posts: 3530
Joined: Fri Apr 13, 2007 2:47 pm

Post » Sun Dec 04, 2011 2:18 pm

Display the 'timer' along with the ActivateTimer variable to see what its doing.
User avatar
Sammygirl500
 
Posts: 3511
Joined: Wed Jun 14, 2006 4:46 pm

Post » Sun Dec 04, 2011 9:17 am

Display the 'timer' along with the ActivateTimer variable to see what its doing.


Done. It's the timer, it's not initialising (constantly '0'). I can see now where the problem lies, but specifically how remains to be seen. Could it be that during GameMode, we're simultaeneously setting the ActivateTimer to 1 and asking if it IS equal to 1 (which in turn would start the timer)?
User avatar
Kelly John
 
Posts: 3413
Joined: Tue Jun 13, 2006 6:40 am

Post » Sun Dec 04, 2011 2:53 am

Did you check the 'timer' variable instantly after activating it the first time? It should count down from 5 seconds to 0.

Also, when you display the timer, use:
%.2f


[EDIT] DOH!
Change this line of code:
short timer
to
float timer
User avatar
Sophie Louise Edge
 
Posts: 3461
Joined: Sat Oct 21, 2006 7:09 pm

Post » Sun Dec 04, 2011 11:59 am

Did you check the 'timer' variable instantly after activating it the first time? It should count down from 5 seconds to 0.

Also, when you display the timer, use:
%.2f


[EDIT] DOH!
Change this line of code:
short timer
to
float timer


Hahahaha! Dude! Great minds think alike! I actually ended up creating a global variable for it, then I noticed this!!!! WHOOPS! Thanks for helping me slog it out over this though :)
User avatar
Lily Something
 
Posts: 3327
Joined: Thu Jun 15, 2006 12:21 pm

Post » Sun Dec 04, 2011 1:37 am

Heh, heh, no problem. I will be having surgery tomorrow so I may not be around much for a while. ;)
User avatar
Nicole M
 
Posts: 3501
Joined: Thu Jun 15, 2006 6:31 am


Return to Fallout 3