Global Variable Not Being Recognized

Post » Fri May 27, 2011 5:31 pm

I've set a debug variable to try and check why this script is not executing. I set the global short variable uvi_meiree_away to -2 manually in the console, but the Debug variable is not being set to 2. It's being set to 1, but the script stops after the next if block. Can anyone tell me what is going on here?

Short stateShort framecountShort DeBugIf ( uvi_meiree_vampire == 0 ) ;stop if she's not a vampire	ReturnElse	Set DeBug to 1EndifIf ( uvi_meiree_away == -2 ) ;Meiree has been locked in the Servant's Quarters	Set DeBug to 2	If ( state == 0 )		servant_meiree->PositionCell -724 -102 -256 0 "Tel Uvirith, Servant's Quarters"		Set state to 1	Elseif ( state == 1 )		Set framecount to ( framecount + 1 )		If ( framecount >= 3 )			servant_meiree->Enable			Set servant_meiree.facefix to 1			Set state to -1			Set uvi_meiree_away to -1		Endif	EndifEndif

User avatar
Jesus Sanchez
 
Posts: 3455
Joined: Sun Oct 21, 2007 11:15 am

Post » Fri May 27, 2011 5:42 am

Well, if uvi_meiree is a vampire, then Debug is set to 1 *every* frame, and since uvi_meiree_away is being set to -1 in three frames after you manually set it to -2, Debug isn't reset any further. Other than that, I don't quite see what is going wrong with your script, since it's not clear enoug what it is *supposed* to do and what it doesn't.

I'd recommend you to use MessageBoxes for debugging scripts. Sure, if the script is running every frame, they will be appearing this often, pushing each other out of screen, but even then you can get used to recognizing the pattern, and if something suddenly stops working as intended, you'll notice immediately.
User avatar
Life long Observer
 
Posts: 3476
Joined: Fri Sep 08, 2006 7:07 pm

Post » Fri May 27, 2011 11:42 am

Could there be another script that sets uvi_meiree_away to some other value every frame? If so, and that script runs before this one, your console change will get trampled on.
User avatar
Madeleine Rose Walsh
 
Posts: 3425
Joined: Wed Oct 04, 2006 2:07 am

Post » Fri May 27, 2011 12:04 pm

Sigh, it must be getting late. The whole problem stems from me typing in "Tel Uvirith, Servant's Quarters" instead of "Tel Uvirith, Servant's Quarter". That little s on the end of the cell name killed the script. :facepalm:
User avatar
LuCY sCoTT
 
Posts: 3410
Joined: Sun Feb 04, 2007 8:29 am

Post » Fri May 27, 2011 8:21 am

He, this is the typical kind of typo that makes you appreciate MWEdit :) . Think about using a cell name written with an extra space and imagine the debugging headache without MWEdit error message...

[edit]typo!
User avatar
Milagros Osorio
 
Posts: 3426
Joined: Fri Aug 25, 2006 4:33 pm

Post » Fri May 27, 2011 9:30 am

Yeah, I didn't even realize that the script would compile in the CS with a mis-typed cell name. I thought it would have warned me, but no, it just silently broke with no warning whatsoever. I really should start using MWEdit more often for scripting.
User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am


Return to III - Morrowind