I have a series of lambdas (that is, rings) and I'd like to programmatically create a global block that calls this lambda, retaining context (or at least closed upon variables)
a) what other information do I need to know about the block? (eg category)
b) how would I do that?
ps are we ever going to get metaprogramming in Snap!?
Use for commands or for reporters.
If the block takes inputs, click the right arrowhead at the end of RUN or CALL and you get
into which you can put inputs. (Click the right arrowhead again to get more slots.)
Yes. Although Jens is hesitant about it.
No, my need is to programmatically (that is, in Snap! or JS) create a global block that calls the lambda, I guess with run and call, that's fine
To create a global block with JS, you need to know:
- the category (string)
- the block spec (string)
- is it global? (boolean)
- type (string / command, reporter, or predicate)
- input declarations (JS map object / kind of complicated / defaults, types, options, etc for each input)
Just put the lambda/ring inside the "definition" parameter.
Does that mean if it's local to a sprite or not?
It's true if the block is not local to a sprite.