Problem with ref walking script

Post » Fri May 04, 2012 1:18 am

This script is attached to an ingestible item. The script works fine for the most part, however I get a problem if I run the script in megaton. After the menu selection window shows something causes the script to error, and the next time it is activated from the inventory the script doesn't run and the item is removed and not replaced.

I've tried a lot of things to fix it, but really am not sure what is causing the error. I'm guessing somehow an invalid reference is created which stops the script. Maybe some fresh eyes can spot the problem.

scn b3ToiletReplacerScriptSmallref NewToiletref Toiletref Trigerfloat pxfloat pyfloat pzfloat angzfloat angxfloat angyshort onceshort initshort buttonshort activeshort indexshort numbershort smallshort homebegin ScriptEffectStart   showmessage b3options   set active to 0   player.additem b3ToiletPaper01 1 1Endbegin ScriptEffectUpdateif active == 0   set button to getbuttonpressedif button == 0   set active to 1elseif button == 1   set active to 1   set home to 1elseif button == 2   showmessage b3Remove   set active to 4elseif button == 3   set active to 4endifendifif active == 1set Toilet to getfirstref 0 1label 10if(Toilet)if Toilet.getdisabled == 0  else   set Toilet to ArmorCombatHelmet   set Toilet to getnextref   goto 10   endif  if toilet.getisid DrinkToilet || toilet.getisid DrinkToiletSettlement   set NewToilet to movetoref.placeatme b3SitToiletDirty  elseif toilet.getisid DrinkToiletClean   set NewToilet to movetoref.placeatme b3SitToiletClean  elseif toilet.getisid DrinkToiletCleaner   set NewToilet to movetoref.placeatme b3SitToiletCleaner  elseif toilet.getisid DrinkToiletMetal   set NewToilet to movetoref.placeatme b3SitToiletMetalR   set small to 1  elseif toilet.getisid DrinkToiletMetalV101   set NewToilet to movetoref.placeatme b3SitToiletMetal   set small to 1  else   set Toilet to ArmorCombatHelmet   set Toilet to getnextref   goto 10  endif   set px to Toilet.getpos x   set py to Toilet.getpos y   set pz to Toilet.getpos z   set angz to Toilet.getangle z   set angy to Toilet.getangle y   set angx to Toilet.getangle x   Toilet.disable   NewToilet.disable   NewToilet.moveto player   NewToilet.setpos x px   NewToilet.setpos y py   NewToilet.setpos z pz   NewToilet.setangle z angz   NewToilet.setangle y angy   NewToilet.setangle x angx   NewToilet.enable  if home == 0	  set Triger to movetoref.placeatme b3FlushTrigger  else	  set Triger to movetoref.placeatme b3FlushTriggerHome	  set home to 0  endif   Triger.disable  if small == 1	  Triger.setscale .4	  set small to 0  else	  Triger.setscale .3  endif   Triger.moveto NewToilet   Triger.enable   set Toilet to ArmorCombat   set Toilet to getnextref   goto 10endif   set active to 4endifend
User avatar
ANaIs GRelot
 
Posts: 3401
Joined: Tue Dec 12, 2006 6:19 pm

Post » Fri May 04, 2012 2:15 pm

See if breaking from the loop after 10 attempts any differences arise.

Modify yoru script so when a variable is 10, set it to zero and don't execute goto label 10. That variable is of course incremented while in the loop.

Your problem could be environment , no new refs, or the function doesn't work quite how you expect.
User avatar
Hairul Hafis
 
Posts: 3516
Joined: Mon Oct 29, 2007 12:22 am

Post » Fri May 04, 2012 11:04 am

Still getting nowhere with this...When I fast travel to megaton and use the script it breaks. If I fast travel to megaton, save my game, then exit to main menu and reload that save, the script works. When the script breaks if I exit to main menu I can hear a nasty stuttering noise, like the script is still running (which I guess it is).

Ok well changing the line
set Toilet to getfirstref 0 1


to

set Toilet to getfirstref 21 1

so that it only looks for activators seems to have fixed it. Should have been that way from the start
but I changed it for some reason. Back to seeing if I can break it now.
User avatar
Romy Welsch
 
Posts: 3329
Joined: Wed Apr 25, 2007 10:36 pm


Return to Fallout 3