Timer not working?

Post » Wed Feb 16, 2011 8:52 am

Ok, I'm not sure what problem I'm having with this code...but as soon as it gets to part 7.7 the message "7.7 active." Doesn't quit appearing and the rest of the code isn't proccessed. I'm truly stumped. I tried rearranging it, so that the 7.7 comes before 7.6. That solves the message problem, but the code still doesn't process...

7.4, 7.5 and 7.6 happen at random...any one of these can occur but the outcome is always 7.7 - I just can't get 7.7 to function.
Any ideas? This script is pretty long...but I haven't had any trouble with it up until I added this segment of code.



If ( Part == 7.3 )			If Timer < 2				Set Timer to Timer + GetSecondsPassed										Else						Message "Adding Package."						NpcTarget.Cast ArbPracticeSpell3 NpcTarget						Set Timer to 0						Set Part to 7.4EndifEndifIf ( Part == 7.4 && ScampDead == 1)Messagebox "Student: Wow, that was close!", "Yes it was, but you did well. Go and practice now."NpcTarget.AddScriptPackage ArbLeavePackageSet ScampDead to 0Set Part to 7.7	EndifIf ( Part == 7.5 )If Timer < 5Set Timer to Timer + GetSecondsPassedElseMessagebox "Student: Well this is embarassing.", "Errm...we'll that was unexpected. Go and purchase yourself some new clothes."NpcTarget.AddScriptPackage ArbLeavePackageThiefScamp.DisableSet Timer to 0Set ArbScampSteal.Stop to 0Set Part to 7.7	EndifEndifIf ( Part == 7.6 )Messagebox "Well, I think I understand that perfectly.", "Impressive! Practice what you've learned and return to me when your ready!."Set ScampDead to 0NpcTarget.AddScriptPackage ArbLeavePackageSet Part to 7.7EndifIf  Part == 7.7If Timer1 < 5 Set Timer1 to Timer1 + GetSecondsPassedMessage "7.7 Active"ElseNpcTarget.RemoveScriptPackage ArbLeavePackageNpcTarget.DisableMessage "Setting to 7.8."Set Part to 7.8EndifEndif

User avatar
Russell Davies
 
Posts: 3429
Joined: Wed Nov 07, 2007 5:01 am

Post » Wed Feb 16, 2011 8:02 am

Ok....I retested the script. If either 7.4 or 7.6 is activated 7.7 functions but doesn't display the messagebox "Setting to 7.8" ...7.5 goes to 7.7 but just repeats " 7,7 active" and refuses to execute the else code.
User avatar
Greg Swan
 
Posts: 3413
Joined: Tue Jun 05, 2007 12:49 am

Post » Wed Feb 16, 2011 4:58 am

Make sure Timer1 is a float, not an long/short.
User avatar
Julie Serebrekoff
 
Posts: 3359
Joined: Sun Dec 24, 2006 4:41 am

Post » Wed Feb 16, 2011 5:23 am

Make sure Timer1 is a float, not an long/short.



I just double checked, it's a float. Any other ideas why it isn't working? Should I post the rest of the script?
User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Wed Feb 16, 2011 6:40 am

Print out the timer and see what it's doing... there's really no reason you should see the message, but Timer1 isn't increasing.
User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Tue Feb 15, 2011 9:54 pm

Print out the timer and see what it's doing... there's really no reason you should see the message, but Timer1 isn't increasing.


How would I do that?
User avatar
Jamie Moysey
 
Posts: 3452
Joined: Sun May 13, 2007 6:31 am

Post » Wed Feb 16, 2011 9:49 am

How would I do that?

Grab OBSE and use PrintC "7.7 Active - %f" Timer1 instead of Message "7.7 Active". You can keep an eye on the console by opening it and using the command tdt. It'll fly by fast, but you should at least be able to tell if the numbers are increasing, staying the same, or what's going on.
User avatar
Georgia Fullalove
 
Posts: 3390
Joined: Mon Nov 06, 2006 11:48 pm

Post » Tue Feb 15, 2011 10:07 pm

Proper indenting your code should be the first thing you learn about scripting, it makes it easier to read.
If ( Part == 7.3 ) 	If Timer < 2 		Set Timer to Timer + GetSecondsPassed 	Else 		Message "Adding Package." 		NpcTarget.Cast ArbPracticeSpell3 NpcTarget 		Set Timer to 0 		Set Part to 7.4 	Endif Endif  If ( Part == 7.4 && ScampDead == 1) 	Messagebox "Student: Wow, that was close!", "Yes it was, but you did well. Go and practice now." 	NpcTarget.AddScriptPackage ArbLeavePackage 	Set ScampDead to 0 	Set Part to 7.7 Endif  If ( Part == 7.5 ) 	If Timer < 5 		Set Timer to Timer + GetSecondsPassed 	Else 		Messagebox "Student: Well this is embarassing.", "Errm...we'll that was unexpected. Go and purchase yourself some new clothes." 		NpcTarget.AddScriptPackage ArbLeavePackage 		ThiefScamp.Disable 		Set Timer to 0 		Set ArbScampSteal.Stop to 0 		Set Part to 7.7 	Endif Endif   If ( Part == 7.6 ) 	Messagebox "Well, I think I understand that perfectly.", "Impressive! Practice what you've learned and return to me when your ready!." 	Set ScampDead to 0 	NpcTarget.AddScriptPackage ArbLeavePackage 	Set Part to 7.7 Endif  If  Part == 7.7 	If Timer1 < 5  		Set Timer1 to Timer1 + GetSecondsPassed 		Message "7.7 Active" 	Else 		NpcTarget.RemoveScriptPackage ArbLeavePackage 		NpcTarget.Disable 		Message "Setting to 7.8." 		Set Part to 7.8 	Endif Endif


1. The way you have it coded, the message "7.7 Active" will display constantly, over and over again until 'Timer1' is greater than 5.
2. Since you did not display the entire script, are you setting 'Timer1' to another value anywhere else in your code? Use the 'find' function to search your script.
User avatar
Danielle Brown
 
Posts: 3380
Joined: Wed Sep 27, 2006 6:03 am

Post » Wed Feb 16, 2011 10:13 am

Yes, sorry for the messy scripting, I've never tried taking on a scripting project this big before, its quite the challange and after many hours I let my self get sloppy


and no I created Timer1 specifically for that purpose. I was using timer before, but just incase i missed something I made timer 1 and used it instead. Thats the only time it's used. What I don't understand is why 7.5 causes a problem with 7.7, but 7.4 and 7.6 allow 7.7 to execute fine...I mean, besides the messagebox not popping up
User avatar
Reanan-Marie Olsen
 
Posts: 3386
Joined: Thu Mar 01, 2007 6:12 am

Post » Wed Feb 16, 2011 1:50 am

Logically with what you have given us, it should work. My guess is that Timer1 is 'not' defined as a 'float' variable.
User avatar
sam westover
 
Posts: 3420
Joined: Sun Jun 10, 2007 2:00 pm

Post » Wed Feb 16, 2011 3:43 am

Logically with what you have given us, it should work. My guess is that Timer1 is 'not' defined as a 'float' variable.



I put the message in 7.8 to be the first line of code the script executes, so now 7.8 set will appear but it won't disable my npc or remove the package it added like it's supposed to. NpcTarget.Disable. It doesn't make ANY sense....it works perfectly if 7.4 or 7.6 is executed.... how is 7.5 different? it doesn't change those targets - could this object script be the problem? It sets Target to NpcTarget, but I don't understand how that would change it.



SCN ArbScampStealScriptRef TargetFloat STimerShort StopBegin GameModeIf Stop == 0If STimer < 5Set STimer to STimer + GetSecondsPassedElseSet ArbTraining.ThiefScamp to GetSelfSet Target to ArbTraining.NpcTargetTarget.RemoveallItemsSet ArbTraining.Part to 7.5AddScriptPackage ArbLeaveScampPackageSet Stop to 1EndifEndifIf Stop == 1Message " Test"Set Stimer to 0Set Stop to 2EndifEnd

User avatar
Matt Fletcher
 
Posts: 3355
Joined: Mon Sep 24, 2007 3:48 am

Post » Wed Feb 16, 2011 4:55 am

If you get an infinite Message "7.7 Active", then Timer1 is not set up correctly, or is being reset somewhere else. Otherwise, after 5 seconds you would perform the else condition.

If the else condition is being performed, then if "NpcTarget" is not a Reference ID, then the script could fail and quit right there on the first line of the else condition.
User avatar
Philip Rua
 
Posts: 3348
Joined: Sun May 06, 2007 11:53 am


Return to IV - Oblivion