MenuMode & Timers

Post » Mon Mar 14, 2011 9:04 pm

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
Bonnie Clyde
 
Posts: 3409
Joined: Thu Jun 22, 2006 10:02 pm

Post » Mon Mar 14, 2011 11:01 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

User avatar
Umpyre Records
 
Posts: 3436
Joined: Tue Nov 13, 2007 4:19 pm

Post » Tue Mar 15, 2011 1:19 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



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
Josephine Gowing
 
Posts: 3545
Joined: Fri Jun 30, 2006 12:41 pm

Post » Tue Mar 15, 2011 1:22 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
Louise Dennis
 
Posts: 3489
Joined: Fri Mar 02, 2007 9:23 pm

Post » Tue Mar 15, 2011 4:54 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
i grind hard
 
Posts: 3463
Joined: Sat Aug 18, 2007 2:58 am

Post » Mon Mar 14, 2011 4:39 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
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Tue Mar 15, 2011 3:41 am

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
Andres Lechuga
 
Posts: 3406
Joined: Sun Aug 12, 2007 8:47 pm

Post » Tue Mar 15, 2011 2:03 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.
User avatar
lauren cleaves
 
Posts: 3307
Joined: Tue Aug 15, 2006 8:35 am

Post » Mon Mar 14, 2011 5:28 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.


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
Jonathan Braz
 
Posts: 3459
Joined: Wed Aug 22, 2007 10:29 pm

Post » Mon Mar 14, 2011 4:02 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.)
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Tue Mar 15, 2011 3:27 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.)


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
Isabell Hoffmann
 
Posts: 3463
Joined: Wed Apr 18, 2007 11:34 pm

Post » Mon Mar 14, 2011 3:47 pm

Display the 'timer' along with the ActivateTimer variable to see what its doing.
User avatar
Tai Scott
 
Posts: 3446
Joined: Sat Jan 20, 2007 6:58 pm

Post » Mon Mar 14, 2011 8:06 pm

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
Umpyre Records
 
Posts: 3436
Joined: Tue Nov 13, 2007 4:19 pm

Post » Mon Mar 14, 2011 9:08 pm

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
kelly thomson
 
Posts: 3380
Joined: Thu Jun 22, 2006 12:18 pm

Post » Tue Mar 15, 2011 12:36 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
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Tue Mar 15, 2011 3:55 am

Heh, heh, no problem. I will be having surgery tomorrow so I may not be around much for a while. ;)
User avatar
djimi
 
Posts: 3519
Joined: Mon Oct 23, 2006 6:44 am


Return to Fallout 3