Going back from script to owner

I'm almost done with moving my BloP extension to Snap 5.1.1, but I'm stuck with finding the correct owner of a script.

In 4.0 ScriptMorphs were initialized by passing the script "owner" as a parameter, that is the sprite or stage whom the script belonged to. This is different in 5.1.1, the owner parameter has been removed (even if there still is a comment saying that "I store a back-pointer to my owner, i.e. the object (sprite) to whom my scripts apply.") and I'm unable to find the correct attribute that allows me to find the sprite/stage owner of a script so that I can run it in the correct context.

Thanks in advance for any help
Stefano

Hi Stefano,

yay! Sounds great!

So, in newer versions of Snap! the same scripts can be shared among several sprites, e.g. among clones of the same parent. Therefore there no longer is a direct bi-directional relationship between scripts and sprites.

If you want to know the "receiver" when the user clicks on a block in the scripting area, you can call the block's scriptTarget() function. That assumes, that the IDE is currently showing the scripts for the sprite the user is editing.

If, OTOH you wish to know which sprite a currently active Process is referring to you can call that Process' blockReceiver() method.

Otherwise, i.e. for scripts that are not currently actively edited or running, there is no way to establish a backwards-pointing relationship.

Does that makes sense to you?

Thanks a lot for your help Jens. I had already added a filter to find the receiver, but it wasn't working. So I have spent a few days in learning again how the Snap's thread mechanism works. In the end, I found out that I had used the output of a filter function as a SpriteMorph (instead of taking into account that it was, of course, an array of SpriteMorphs). Anyway, now I know the Snap's internal mechanisms much better!

Thanks again
Stefano