Rob Walch

> getPropertyDescriptionList is called when you recompile a script, and when
> you give the behavior inspector or PI behavior tab focus.
> 
> When triggered by recompiling the script, currentSpriteNum will equal 0,
> otherwise, it will equal the selected sprite number.
> 
> spritenum is a runtime property of a sprite, and is not initialized in
> authoring for the object receiving the getPropertyDescriptionList event -
> just check the 'me' there in the debugger... it's the script() receiving
> the
> event, not a behavior instance in the sprite's scriptInstanceList!
> 
> Here's something to chew on:
> 
> on getPropertyDescriptionList(me)
>   if _player.currentSpriteNum then
>       _list = sprite(player.currentSpriteNum).scriptList
> --look at the member's in this script
> --if script(_member) = me then you can grab the properties already set
> --hmm how can that be used?
> return [#prop:[#comment:"",#default:1,#format:#integer,#range:[1,2,3]]]
>   end if
> end
> 
> It gets deep!
> -Walch

-----------------------------------------------

Irv Kalb

> I'm a little familiar with that write-up, maybe I can help.  While
> you can have code in a GPDL, you generally put code in there that
> will help you build up lists, or provide selections for the resulting
> Parameter Dialog Box.
> 
> The basic thing that is going wrong in your script is that GPDL does
> not run at run-time, it runs at author time.  Therefore, the variable
> "currentSpriteNum" doesn't have a value.
> 
> I put a breakpoint after the first line of code in your GPDL and
> found that currentSpriteNum had a value of zero.  Then stepping
> through the code, it is trying to get the locH and locV of sprite 0.
> Since sprite 0 is not a real sprite, the locH and locV should not be
> trusted.  Like you, I found (after converting
> _player.currentSpriteNum to the currentSpriteNum so I could do this
> in DMX), that there must be a difference in dot syntax versus verbose
> syntax which gives you the error.
> 
> However, this is all unimportant.  The real problem with your code is
> that GPDL runs at author-time rather than a run-time.  And at
> author-time, there are no Director sprites.  The simple solution is
> code that refers to sprites and sprite locations should be moved into
> the on beginSprite handler.  on beginSprite runs right after Director
> "instantiates" each sprite.
> 
> Further, "currentSpriteNum" is not needed here.  I suggest declaring
> and using "spriteNum" instead.  It is automatically given the correct
> value at runtime.  From the Lingo Dictionary:
> 
> This property was more useful during transitions from older movies to
> Director6, when behaviors were introduced.  It allowed some
> behavior-like functionality without having to completely rewrite
> Lingo code.  It is not necessary when authoring with behaviors and is
> therefore less useful in the past.
> 
> 
> Bottom line:
> 
> property spriteNum
> property pSprite
> property pStartH, pStartV
> 
> on getPropertyDescriptionList  -- no "me" needed here
> -- do whatever you want to create a property list to be returned to
> define the dialog box
> end
> 
> on beginSprite me
>    pSprite = sprite(spriteNum)
>    pStartH = pSprite.locH
>    pStartV = pSprite.locV
> end
> 
> 
> Irv

Thanks folks, that cleared the situation indeed. So it turns out that I'd
better abstain using _player.currentSpriteNum as it used to be useful in the
olden times. The following solution is way less buggy:

Whether:

property pSprite
property pStartH, pStartV

on beginSprite(me)
  pSprite = (me.spriteNum)
  pStartH = sprite(pSprite).locH
  pStartV = sprite(pSprite).locV
end

on getPropertyDescriptionList(me)
  -- leave this handler for automating your authoring
end
---------------

Or:

property spriteNum
property pStartH, pStartV

on beginSprite(me)
  pStartH = sprite(spriteNum).locH
  pStartV = sprite(spriteNum).locV
end

on getPropertyDescriptionList(me)
  -- leave this handler for automating your authoring
end


Thanks a lot

--------------------
Petro O. Bochan, M.A.
Assistant Professor
Dept. of Foreign Languages
College of History
Chernivtsi National University
Ukraine

E-mail: [EMAIL PROTECTED]
Tel (home): +03722 71895
Tel (office): +0372 550646



[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL 
PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping 
with programming Lingo.  Thanks!]

Reply via email to