One script bugging out another

Post » Sat Nov 07, 2009 12:06 pm

I just had the strangest bug ever. I have two mods. One has an activator that sets a variable in a persistent object. The other is a ring that uses OnPCEquip to trigger a summon.

Now, after much detective work, I figured out that the activator that was supposed to trigger a variable on the persistent object, was triggering the ring script! I looked at both scripts, and they seemed to be perfectly fine. On their own, they each worked perfectly. However, when I carried the ring into the room, the activator started malfunctioning and started triggering the ring instead of doing what it was supposed to. So, instead of causing an object in the room to move, it summoned the creature that the ring is set to summon!

Anway, I tried equipping the ring (I had never done so before because I just loaded the mod) and its script worked fine. I then tried triggering the activator again, and it worked perfectly fine! So it seems, for some strange reason, that the ring's script needed to be triggered once in order to stop it from causing this other script to bug out. I have never run into anything like this before. I have several other rings that work exactly the same way, and none of them have ever caused a problem like this. In fact, I had a second ring that worked exactly the same in my inventory at the same time, also never used before, and it caused no problem at all.

I would just like to know if anyone has any idea why that could have happened. It's the most inexplicable bug I've come across in a long time.
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Sat Nov 07, 2009 5:03 am

Hmmm... it is a little difficult without the scripts source, anyway are you certain that there are not possible same ID name conflicts in different objects used before -> operator, in .esp or (eventually) used saved game?.
If not, maybe renaming every object/script involved with different new, unique ids?
User avatar
james kite
 
Posts: 3460
Joined: Sun Jul 22, 2007 8:52 am

Post » Sat Nov 07, 2009 2:22 pm

It's definitely not that. The objects are from two different mods that I'm working on, so they even have completely different naming prefixes. I also tried checking references persist on everything, not just the called object that's supposed to move. I even checked it off on the ring, and that did nothing. Only activating the ring in the game fixed it. The problem is completely solved by activating the ring in game, but I still want to know why it is bugging out at all.

This is the ring script. Pretty simple stuff:

Begin PGA_SummonRingScript; Summoning ring for creature companion - used instead of standard telepathy ringShort OnPCEquipShort PCSkipEquipShort buttonShort doOnceIf ( doOnce == -1 )	ReturnElseif ( doOnce == 1 )	Set PCSkipEquip to 0	Set OnPCEquip to 0	ReturnEndifSet PCSkipEquip to 1If ( MenuMode )	ReturnEndifIf ( OnPCEquip == 1 )	If ( PGA_packguar->GetHealth > 0 ) ;must be targeted to creature		MessageBox "Summon pack guar?" "Yes" "No"		Set button to -1		Set OnPCEquip to 2	Else		MessageBox "Your pack guar is dead."		Set OnPCEquip to 0		Set PCSkipEquip to 0		Set doOnce to -1		Return	EndifElseif ( OnPCEquip == 2 )	Set button to GetButtonPressed	If ( button == -1 )		Return	Elseif ( button == 0 )		If ( GetInterior == 0 ) ;exterior			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		ElseIf ( GetPCCell "Mournhold, Godsreach" == 1 ) 	;Trib fake exteriors			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		ElseIf ( GetPCCell "Mournhold, Great Bazaar" == 1 )			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		ElseIf ( GetPCCell "Mournhold, Plaza Brindisi Dorom" == 1 )			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		ElseIf ( GetPCCell "Mournhold, Temple Courtyard" == 1 )			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		ElseIf ( GetPCCell "Mournhold, Royal Palace: Courtyard" == 1 )			Set PGA_portflw to 2			If ( ScriptRunning PGA_FollowPortS == 0 )				StartScript PGA_FollowPortS			Endif		Else 	;not same cell and not an accessible cell			MessageBox "You can't summon your pack guar here"			Set OnPCEquip to 0			Return		Endif	Else		Set OnPCEquip to 0		Return	EndifEndifEnd


Here's the activator script, which is a bit more complicated, and the script for the object that it moves as well.

Begin Uvi_UT_Elevator_Switch; created by Stuporstar; activator for elevator in upper tower; script for moving plug is found in UT_ElevatorPlugShort controlvarShort buttonIf ( MenuMode == 1 )	ReturnEndif; check to make sure plug is not currently movingIf ( OnActivate == 1 )	If ( "uvirith_movableplug_UT".Moving != 0 )		If ( "uvirith_movableplug_UT".Moving != 4 )			If ( "uvirith_movableplug_UT".Moving != 8 )				If ( "uvirith_movableplug_UT".Moving != 12 )					If ( "uvirith_movableplug_UT".Moving != 17 ) ;only used one more time to get plug back into position						Set controlvar to 0						Return					Endif				Endif			Endif		Endif	Endif	If ( Player->GetItemCount "key_teluvirith" > 0 )		If ( controlvar == 0 )			If ( "uvirith_movableplug_UT".Positioner == 4 ) ;basemant				MessageBox "The elevator is currently at the secret lab. Which floor would you like it to stop at?" "First" "Second" "Third" "Nevermind"				Set controlvar to 1			Elseif ( "uvirith_movableplug_UT".Positioner == 3 ) ;third floor				MessageBox "The elevator is currently on the third floor. Which floor would you like it to stop at?" "Secret Lab" "First" "Second" "Nevermind"				Set controlvar to 2			Elseif ( "uvirith_movableplug_UT".Positioner == 2 ) ;second floor				MessageBox "The elevator is currently on the second floor. Which floor would you like it to stop at?" "Secret Lab" "First" "Third" "Nevermind"				Set controlvar to 3			Elseif ( "uvirith_movableplug_UT".Positioner == 1 ) ;first floor				MessageBox "The elevator is currently on the first floor. Which floor would you like it to stop at?" "Secret Lab" "Second" "Third" "Nevermind"				Set controlvar to 4			Endif		Endif	Else		MessageBox "You need the Tel Uvirith Key to activate this switch."		AddTopic "Tel Uvirith Key"		Return	EndifEndifIf ( controlvar > 0 )	Set Button to GetButtonPressed	If ( Button == -1 )		Return	EndifElse	Set Button to 0EndifIf ( controlvar == 1 ) ;moving plug from basemant	If ( Button == 0 )		Set "uvirith_movableplug_UT".Moving to 13		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 1 )		Set "uvirith_movableplug_UT".Moving to 14		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 2 )		Set "uvirith_movableplug_UT".Moving to 15		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 3 )		Set controlvar to 0	EndifElseif ( controlvar == 2 ) ;moving plug from top floor	If ( Button == 0 )		Set "uvirith_movableplug_UT".Moving to 11		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 1 )		Set "uvirith_movableplug_UT".Moving to 10		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 2 )		Set "uvirith_movableplug_UT".Moving to 9		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 3 )		Set controlvar to 0	EndifElseif ( controlvar == 3 ) ;moving plug from second floor	If ( Button == 0 )		Set "uvirith_movableplug_UT".Moving to 7		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 1 )		Set "uvirith_movableplug_UT".Moving to 6		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 2 )		Set "uvirith_movableplug_UT".Moving to 5		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 3 )		Set controlvar to 0	EndifElseif ( controlvar == 4 ) ;moving plug from first floor	If ( Button == 0 )		Set "uvirith_movableplug_UT".Moving to 1		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 1 )		Set "uvirith_movableplug_UT".Moving to 2		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 2 )		Set "uvirith_movableplug_UT".Moving to 3		Set "uvirith_movableplug_UT".toggleSound to 1		Set controlvar to 0	Elseif ( Button == 3 )		Set controlvar to 0	EndifEndif; Moving states: local variable for UT elevator plug; 0 At rest in original position on floor one ( Position 1 ); 1 Moving from first floor to basemant; 2 Moving from first floor to second; 3 Moving from first floor to third; 4 At rest on second floor - ( Position 2 ); 5 Moving from second to third floor; 6 Moving from second to first floor; 7 Moving from second floor to basemant; 8 Set on third floor - ( Position 3 ); 9 Moving from third to second floor; 10 Moving from third to first floor; 11 Moving from third floor to basemant; 12 Set on basemant floor - ( Position 4 ); 13 Moving from basemant to first floor; 14 Moving from basemant to second floor; 15 Moving from basemant to third floorEnd


Begin Uvi_UT_ElevatorPlug; created by Stuporstar; activated by 4 switches in the upper tower, acts like an elevator.; just a note for other modders! make sure a collision wall is placed below the floor when making an "elevator" like this one. It gets really buggy if you let it drop into nothingness.Short PositionerShort MovingShort toggleSoundShort StartPosShort StartPosYFloat TimerIf ( MenuMode == 1 )	ReturnEndifIf ( StartPos == 0 )	Set StartPos to ( GetPos, z )EndifIf ( StartPosY == 0 )	Set StartPosY to ( GetPos, y )EndifIf ( Moving == 0 ) ;first floor	If ( Positioner != 1 )		Set Positioner to 1	Endif	SetPos, z, StartPos	ReturnElseif ( Moving == 4 ) ;second floor	If ( Positioner != 2 )		Set Positioner to 2	Endif	SetPos, z, 1000	ReturnElseif ( Moving == 8 ) ;third floor	If ( Positioner != 3 )		Set Positioner to 3	Endif	SetPos, z, 1250	ReturnElseif ( Moving == 12 ) ;basemant	If ( Positioner != 4 )		Set Positioner to 4	Endif	SetPos, z, -20	ReturnElseif ( Moving == 17 )	Set Moving to 18	ReturnEndifIf ( toggleSound == 1 )	PlaySound "Door Stone Open"	Set toggleSound to 0EndifIf ( Moving == 1 )	MoveWorld Z, -125Elseif ( Moving == 2 )	MoveWorld Z, 125Elseif ( Moving == 3 )	MoveWorld Z, 125Elseif ( Moving == 5 )	MoveWorld Z, 125Elseif ( Moving == 6 )	MoveWorld Z, -125Elseif ( Moving == 7 )	MoveWorld Z, -125Elseif ( Moving == 9 )	MoveWorld Z, -125Elseif ( Moving == 10 )	MoveWorld Z, -125Elseif ( Moving == 11 )	MoveWorld Z, -125Elseif ( Moving == 13 )	MoveWorld Z, 125Elseif ( Moving == 14 )	MoveWorld Z, 125Elseif ( Moving == 15 )	MoveWorld Z, 125;Elseif ( Moving == 16 ) - no longer used;	MoveWorld Y, -75Elseif ( Moving == 18 ) ; used one more time to get plug back into hall for people upgrading from old version	MoveWorld Y, 75EndifIf ( Timer > 10 ) ;twice + half	If ( Moving == 11 ) ;twice + half		Set Moving to 12		Set Timer to 0		Return	Elseif ( Moving == 15 ) ;twice + half		Set Moving to 8		Set Timer to 0		Return	EndifElseif ( Timer > 8 ) ;twice	If ( Moving == 7 ) ;twice		Set Moving to 12		Set Timer to 0		Return	Elseif ( Moving == 14 ) ;twice		Set Moving to 4		Set Timer to 0		Return	EndifElseif ( Timer > 6 ) ;once + half	If ( Moving == 3 ) ;once + half		Set Moving to 8		Set Timer to 0		Return	Elseif ( Moving == 10 ) ;once + half		Set Moving to 0		Set Timer to 0		Return	EndifElseif ( Timer > 4 ) ;once	If ( Moving == 1 ) ;once		Set Moving to 12		Set Timer to 0		Return	Elseif ( Moving == 2 ) ;once		Set Moving to 4		Set Timer to 0		Return	Elseif ( Moving == 6 ) ;once		Set Moving to 0		Set Timer to 0		Return	Elseif ( Moving == 13 ) ;once		Set Moving to 0		Set Timer to 0		Return;	Elseif ( Moving == 16 ) ;out - no longer used;		Set Moving to 17;		Set Timer to 0;		Return	Elseif ( Moving == 18 ) ;in - set one more time		If ( Positioner == 1 )			SetPos, y StartPosY			Set Moving to 0			Set Timer to 0			Return		Elseif ( Positioner == 2 )			SetPos, y StartPosY			Set Moving to 4			Set Timer to 0			Return		Elseif ( Positioner == 3 )			SetPos, y StartPosY			Set Moving to 8			Set Timer to 0			Return		Elseif ( Positioner == 4 )			SetPos, y StartPosY			Set Moving to 12			Set Timer to 0			Return		Endif	EndifElseif ( Timer > 2 ) ;half	If ( Moving == 5 ) ;half		Set Moving to 8		Set Timer to 0		Return	Elseif ( Moving == 9 ) ;half		Set Moving to 4		Set Timer to 0		Return	EndifEndifSet Timer to ( Timer + GetSecondsPassed ); Moving states: local variable for UT elevator plug; 0 At rest in original position on floor one ( Positioner 1 ); 1 Moving from first floor to basemant; 2 Moving from first floor to second; 3 Moving from first floor to third; 4 At rest on second floor - ( Positioner 2 ); 5 Moving from second to third floor; 6 Moving from second to first floor; 7 Moving from second floor to basemant; 8 Set on third floor - ( Positioner 3 ); 9 Moving from third to second floor; 10 Moving from third to first floor; 11 Moving from third floor to basemant; 12 Set on basemant floor - ( Positioner 4 ); 13 Moving from basemant to first floor; 14 Moving from basemant to second floor; 15 Moving from basemant to third floor; 16 Moving out of tunnel when player is levitating - no longer used; 17 Set in out position ( no Position set ) - no longer used, reset for players upgrading from older version; 18 Moving back into tunnel - only used one more time for players upgrading from previous versionsEnd


What actually happens is (only if the ring has never been activated and it's in my inventory) the activator pops up its menu, asking which floor you want to go to. Once a button is pressed, it sets the ring's OnPCEquip to 2 (no matter what choice I make) and I get the message "you can't summon your packguar here". The activator gets stuck on its controlvar, and has to be reset to 0 in the console before it will do anything again, and the movable plug does nothing because it's variables aren't being set.

I'm also going to post another script that once messed with this activator in the same way until I fixed it.

begin BOH_Script_Telvanni;script for inventory itemshort OnPCEquipshort buttonshort statefloat pXfloat pYfloat pZfloat pAlong pcCelllong filenameif ( state != 0 )   ;do nothing hereelseif ( OnPCEquip == 1 )   if ( BOHReloadDetect->GetScale > 2 )  ;the container has been activated this session      BagOfHoldingC_Telvanni->activate      set OnPCEquip to 0   else      MessageBox "You need to summon the bag to restore its magical link. Would you like to do this now?" "Yes" "No"      set OnPCEquip to 2   endifelseif ( OnPCEquip == 2 )   set button to ( GetButtonPressed )   if ( button == -1 )      return   elseif ( button == 0 )      set state to 1      BOHReloadDetect->SetScale 0.1  ;let the container know it needs to return the player to stored position   else  ;cancel      set state to 0   endif   set OnPCEquip to 0endifif ( MenuMode )   returnelseif ( state != 1 )   returnendifset pX to ( player->GetPos x )set pY to ( player->GetPos y )set pZ to ( player->GetPos z )set pA to ( player->GetAngle z )setx pcCell to xPCCellIDsetx filename to xStringBuild "BOHcoords"xFileRewind filenamexFileWriteLong filename pXxFileWriteLong filename pYxFileWriteLong filename pZxFileWriteLong filename pAxFileWriteString filename pcCellStartScript BOH_helper_scrset state to 0end


Now, I don't remember what was wrong with it before I fixed it, because it works perfectly fine now, but I had to fix this script in order to make it stop messing with the same activator. What was happening was the object (in this case a dummy inventory bag) was doing something to the activator so that instead of moving the platform, activating the activator set the state of the bag. Again, by setting OnPCEquip to 2 after the menu button was selected.

I also had another ring in my inventory with a very similar script to the first one I posted (again, not activated in the game at that point). It had the exact same structure and variables, just doing something different in the menu choices. It did not have the same problem as the first script at all.
User avatar
Robert DeLarosa
 
Posts: 3415
Joined: Tue Sep 04, 2007 3:43 pm

Post » Sat Nov 07, 2009 10:23 am

More than anything this sounds like a http://wryemusings.com/Wrye%20Mash.html#RenumberRefs bug. Usually the MCP catches this kind of thing. Have you tried Wrye Mash's 'renumber refs' function?
User avatar
[ becca ]
 
Posts: 3514
Joined: Wed Jun 21, 2006 12:59 pm

Post » Sat Nov 07, 2009 5:04 am

I haven't tried that. I'll give it a test and see. I still have the save where the problem started. I am using the latest MCP on this system, but it may not have caught it.
User avatar
мistrєss
 
Posts: 3168
Joined: Thu Dec 14, 2006 3:13 am

Post » Sat Nov 07, 2009 2:03 am

I'd try changing the uvirith_movableplug_UT.Positioner, uvirith_movableplug_UT.Moving and uvirith_movableplug_UT.ToggleSound to global variables.
User avatar
Christina Trayler
 
Posts: 3434
Joined: Tue Nov 07, 2006 3:27 am

Post » Sat Nov 07, 2009 1:19 pm

This is a wild shot in the dark, but if uvirith_movableplug_UT is a physical object as I'm assuming, you could also try substituting the script name UT_ElevatorPlug instead, provided the script is unique to that object - a little more direct route to the external reference.
User avatar
Pete Schmitzer
 
Posts: 3387
Joined: Fri Sep 14, 2007 8:20 am

Post » Sat Nov 07, 2009 9:11 am

I've just noticed that stupid ring is causing script conflicts with other scripts in my other mod. Those scripts have worked perfectly fine for years, so I'm not thinking about changing them until I test the ref conflict theory. I haven't yet tried reordering refs yet because I don't want to cause doubling errors in my current test game, but I may try deleting the ring and making a brand new one that's exactly the same except for the ID.
User avatar
Caroline flitcroft
 
Posts: 3412
Joined: Sat Nov 25, 2006 7:05 am

Post » Sat Nov 07, 2009 1:39 am

Ok, it's been a while and I finally had a chance to test whether or not it's a ref conflict. I reordered refs in Mash on the mod that contains the problem ring, and now all my problems are fixed. So, no need to alter scripts or muck about. It's all good now.
User avatar
P PoLlo
 
Posts: 3408
Joined: Wed Oct 31, 2007 10:05 am


Return to III - Morrowind