Home 0 SoundRaider 0 Director 0 Faust 0 Nectarine 9 0 Personal 0
 
 XObjects
 Shockwave Gallery
 Technical Guide for Director Developers
 Director Tips and Tricks
 
 Director Users Group
 DUG Members List

© Andy Wilson, 1998

Tips and Tricks: Fixing Bad Scripts

If you've ever come up against that director bug where all your scripts get confused about what type of script they are (ie. you get 'handler not found' errors all over the place, and you can't create new instances from your parent scripts) the usual solution is to change the scriptType of the offending scripts to something arbitrary, save and compact the movie, then change the scriptTypes back to what it should be and save the movie all over again.

Here's a little bit of code that will do all the hard work for you... be warned though, you should 'Save As' your movie and all external cast libraries into a new directory before using this script to make sure you don't damage your movie. Having said that, with careful use I think this script is just the thing for those late nights when you have only hours left to the deadline and your movie scripts suddenly go belly up.

The code is reproduced below, but you can save your self a lot of effort by simply downloading the script and dropping it into your behaviours library. Whenever you neded it just open the library, copy the script over into your movie, and type 'fixScripts' into the message window.

on fixScripts
  set scrpts = []
  set cntLibs = the number of castLibs
  repeat with x = 1 to cntLibs
    setAt (scrpts, x, [])
    set libScrpts = getAt (scrpts, x)
    set cntMems = the number of ¬
	    members of castLib x
    if not cntMems then next repeat
    repeat with y = 1 to cntMems
      if the type of member y of ¬
	      castLib x <> #empty then
        if the type of member y of ¬
	        castLib x <> #script then
          set scTxt = the scriptText of ¬
	          member y of castLib x
          setAt  (libScrpts, y, scTxt)
          set the scriptText of member y ¬
	         of castLib x = EMPTY
        else
          set styp = the scriptType of ¬
             member y of castLib x
          if offset("on fixScripts", the ¬
		      scriptText of member y of ¬
			     castLib x) then
            setAt (libScrpts, y, #none)
          else
            setAt (libScrpts, y, styp)
            if styp = #movie then
              set the scriptType of member y ¬
	             of castLib x = #score
            else
              set the scriptType of member y ¬
	           of castLib x = #movie
            end if
          end if
        end if
      else
        setAt (libScrpts, y, #none)
      end if
    end repeat
  end repeat
  saveMovie
  set cnt = count (scrpts)
  if not cnt then exit
  repeat with x = 1 to cnt
    set minLst = getAt (scrpts, x)
    set cnt2 = count (minLst)
    if not cnt2 then next repeat
    repeat with y = 1 to cnt2
      set val = getAt (minLst, y)
      if val <> #none then
        if symbolP(val) then
          set the scriptType of member y ¬
	          of castLib x = val
        else
          if stringP(val) then
            set the scriptText of member y
			    of castLib x = val
          end if
        end if
      end if
    end repeat
  end repeat
  saveMovie
end
 
There are currently users connected. You have viewed 1 pages. Unless otherwise stated, all content is ©1996-2003 Andy Wilson. If you have any questions or suggestions you can mail me: andyw at dircon dot co dot uk. This site is hosted by LShift Ltd.