Where does proc come from in Javascript functions

I only resort to evil JS when absouluety necssary as I don't like it, don't really understand it (and don't really want to) :slight_smile:

But when I HAVE to hack someone else's code I see a lot of functions likes this


and I think to myself - where does proc come from?

Snap! provides it as an argument when calling JS Functions, because in OOP style, the JS procedure needs some starting point to access the data structures of the script, the sprite, the world, whatever.

So it's always the final input to the JS Function. However many inputs the CALL block provides, the JS code gets one more. If it doesn't pay attention to that extra argument, nothing bad happens, but it's there if you need it.

Now I understand :slight_smile:

I think you can also access proc with this, since the procedure is the caller of the JSFunction.

Not exactly...
untitled script pic (12)

this is the sprite that is running the script.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.