Jeremy,

> Does every function in the behavior script need a return me 
> or just the new function?

First, to be clear, you're talking about _parent_scripts_ right? A behavior utilizes a 
beginSprite handler not a new handler. Yes, under the hood behaviors and parent 
scripts are nearly identical (their creation methods are different), but it's 
important to set the context. 

With _all_ handlers the golden rule is that it only needs to return something when you 
want it to. In the case of making a new script object using the following syntax:

s = script("playerscript").new(playername)

what you need is for the new handler in that script to get triggered, spawning the 
object into memory and then you need a reference to that object _returned_ to you that 
will be stored in the variable s, so therefore in this case you must have the "return 
me" (being more verbose you are asking it to return a reference to "me" - the newly 
formed script in memory) at the end of your new handler.

Let's say you have another handler that will do some work for you and computer a value 
(the player's wealth for example) then the handler wouldn't return a "me" reference, 
instead you'd return the data reference. For example you might imagine this handler in 
that parent script:

on computePlayerWealth 

  -- calculate their wealth, imagine that
  -- pGold and pSilver are declared props
  -- of the script object
  tWealth = pGold + (0.5 * pSilver)

  -- return the computed wealth
  return tWealth

end

You see, in that case you don't need the script object's reference (me) returned, you 
need to have the computed wealth value returned. 

Therefore to make a short story long, no, all your handlers do not need to return me, 
only the new one is *required* to do so so that you can store a reference to the newly 
spawned object in a variable (if you don't store a reference then the script object 
disappears from memory - it won't stick).

Does that help?

Cheers,
Tom

.
[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