showmessage not displaying updated variables

Post » Fri Apr 08, 2011 1:04 am

Thank you for looking at my problem.
I'm having a problem with a Message not displaying updated variables. The Showmessage is a scoreboard that is displayed every second, with a timer displayed that counts down from 60 -> 0, a Hoghscore that is read from a global variable, and a score that is read from a local variable. The local variable is "score" which is held in a script, SIMScoreBoard. The script is attached to the term, which is persistent and has a ref name of SIMTerm. There is an NP and a custom CGTarget-type object(the shooting gallery target that spins around), every time you shoot either of the targets you get a point. The points are accumulated through a script attached to the target which say " set SIMTerm.score to (SIMTerm.score + 1) ". The score is being accumulated properly, as I placed a test-activator which opens a messagebox that displays, SIMterm.score. This variable increments with each hit properly, however the scoreboard message that is constantly displayed, and updated, dos not update the score. It does count down properly though.


here is the code for the scoreboard:

The script is attached to a terminal which has a menu to begin the timer.
scn SIMScoreboardScrfloat timershort timeshort stateshort scoreshort highscoreBegin GameModeif state == 0	if SIMQuestBegin == 1; this is assigned to 1 when selected from the terminal menu		set state to 1	endifendifif state == 1; open door, and initialize variables	OffDoorBig01SIMMuseum01.unlock	OffDoorBig01SIMMuseum01.playsound3d DRSRivetCitySmallUnlock	set time to 60	set timer to 0	set score to 0	set highscore to SIMmuseumHighScore		set state to 2endifif state == 2; core area, updates variables and displays message;	if ( menumode == 0 ); even with this in, The countdown continues in Pipboy, Vats, etc...		if ( time >= 0 )			if (SIMMuseumTargetP01.isAnimPlaying == 1)				set score to ( score + 1 ); I'm aware that this adds points as long as the animation is playing, but I left it this way for testing for now.			endif                        ; points are also assigned by scripts attached to the targets themselves. testing both possibilites			if ( SIMTargetNPCME01.getkillingblowlimb == 0 )				set score to ( score + 5 )			endif			if ( SIMTargetNPCME01.getkillingblowlimb == 1 )				set score to ( score + 10 )			endif			if ( SIMTargetNPCME01.getkillingblowlimb == 3 )				set score to ( score + 2 )			endif			if ( SIMTargetNPCME01.getkillingblowlimb == 5 )				set score to ( score + 2 )			endif			if ( SIMTargetNPCME01.getkillingblowlimb == 7 )				set score to ( score + 2 )			endif			if ( SIMTargetNPCME01.getkillingblowlimb == 10 )				set score to ( score + 2 )			endif									set timer to getsecondspassed			set time to ( time - timer );			set SIMmuseumScore to score			showmessage SIMmsgScoreboard highscore SIMmuseumScore score time; The message displays Highscore, score, ScoreLocal, and Time. the time works perfectly, the highscore displays at least, but neither the global SIMMuseumScore or local score variables update		endif		if time <= 0			set state to 3		endif		;	endifendifif state == 3	if score > highscore		set SIMmuseumHighScore to score	endif	set SIMQuestBegin to 0;	disable;	markfordelete	set state to 4	endifif state == 4	set timer to 0	set timer to (timer + getsecondspassed)	if (timer > 2)		showmessage SIMmsgScoreboard highscore SIMmuseumScore score time		set state to 5	endif;This doesn't show up eitherendifend



If anyone can decipher anything out of this, your asstance would be great. I know it can work, I did it 2 years ago, but i lost the file and can't remember how I did it anymore.
User avatar
Taylor Thompson
 
Posts: 3350
Joined: Fri Nov 16, 2007 5:19 am

Post » Thu Apr 07, 2011 11:36 pm

Not sure about the first part, but there's a problem with this block of code:

if state == 4
set timer to 0 <---- This will prevent timer from ever getting higher than the delay between frames
set timer to (timer + getsecondspassed)
if (timer > 2)
showmessage SIMmsgScoreboard highscore SIMmuseumScore score time
set state to 5
endif
;This doesn't show up either
endif

getsecondspassed returns the time since the last time it was called, so unless your delay between frames is more than 2 seconds (which it won't be if this is an object script), your message will never be displayed.
User avatar
Rich O'Brien
 
Posts: 3381
Joined: Thu Jun 14, 2007 3:53 am

Post » Fri Apr 08, 2011 2:08 am

if state == 4	set timer to 0	set timer to (timer + getsecondspassed)	if (timer > 2)		showmessage SIMmsgScoreboard highscore SIMmuseumScore score time		set state to 5	endif;This doesn't show up eitherendif


Yea this is your main problem. Every single frame it sets the timer to 0, so it never goes up past about 1/30 (depending on your framerate) Plus that will only show it once after 2 seconds. Change it to this.

If State == 4   If Timer < 2        Set timer to (timer + getsecondspassed)   Else        Showmessage SIMmsgScoreboard highscore SIMmuseumScore score time        Set state to 5  EndIfEndIf


This will show the message once after 2 seconds properly.
User avatar
Isabel Ruiz
 
Posts: 3447
Joined: Sat Nov 04, 2006 4:39 am

Post » Thu Apr 07, 2011 9:43 pm

if state == 4	set timer to 0	set timer to (timer + getsecondspassed)	if (timer > 2)		showmessage SIMmsgScoreboard highscore SIMmuseumScore score time		set state to 5	endif;This doesn't show up eitherendif


Yea this is your main problem. Every single frame it sets the timer to 0, so it never goes up past about 1/30 (depending on your framerate) Plus that will only show it once after 2 seconds. Change it to this.

If State == 4   If Timer < 2        Set timer to (timer + getsecondspassed)   Else        Showmessage SIMmsgScoreboard highscore SIMmuseumScore score time        Set state to 5  EndIfEndIf


This will show the message once after 2 seconds properly.



Ok. I fixed that problem but that is just a test section of the script. The real problem in the execution is that during state == 2 the message does not update the score displayed.

I did get the score to display using another different activator. This ran on GameMode while the global variable BeginQuest == 1, this is set through the terminal menu which has the original script attached to it. This second activator displays a message every second, which displays only the score, but it displays, "SimTerm.score", taking it from the ref of the terminal and pullingthe score variable out of the attached script(The one that I posted above).

However, if I add a timer to the message, then it again fails to update properly.
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Fri Apr 08, 2011 12:27 am

Ok, I think I determined the answer. The problem is that it is sending a showMessage command every frame. This created a gigantic stack of message to cycle through. I'm going set a condition to only display a message on each full second and see if it fixes the problem.
User avatar
naana
 
Posts: 3362
Joined: Fri Dec 08, 2006 2:00 pm

Post » Thu Apr 07, 2011 11:22 pm

OK, that did the trick.

Here's the final working script ...

scn SIMrangeP01ScoreScriptshort scorefloat timerfloat timer2short timeshort stateBegin OnActivate	if state == 0		set SIMrangeP01Begin to 1	elseif state == 1		set state to 2	endifendBegin GameMode	if state  == 0		if SIMrangeP01begin == 1			set state to 1			set timer to 0			set time to 61;The display starts at 60-1 -> 0-1, so at 61 it will display 60-0 instead of 59-(-1)			set score to 0		endif	endif	if state == 1		if SIMrangeP01begin != 1			set state to 2		else			set timer to (timer + getsecondspassed)			if time >= 1				if timer >= 1					set time to ( time - 1 )					set timer to 0					showmessage SIMmsgrangeP01ShowScore SIMrangeP01HighScore score time				endif			else				set simrangeP01Begin to 2				set state to 2			endif		endif	endif		if state == 2		;reset targets if necessary		;check highscore		if SIMrangeP01HighScore < score			showmessage SIMmsgrangeP01HighScore score SIMrangeP01HighScore			set state to 3		else			set state to 0		endif	endif	if state == 3		set SIMrangeP01HighScore to score		set state to 0	endifend

User avatar
Britney Lopez
 
Posts: 3469
Joined: Fri Feb 09, 2007 5:22 pm


Return to Fallout 3