I'm trying to make a "change [var] by [num]" just like the built-in one, except it reports the final value.
If I make var a special variables list, then use set, I'm just reassigning the var reference rather than the reassigning the actual var's value. If I make var an upvar, that doesn't seem to be what I want at all.
[scratchblocks]
(change (variable) by (number) :: variables) :: control hat
script variables (a) @delInput @addInput:: grey
set [a v] to (primitive [var_get(name) v] (variable) @delInput @addInput:: grey)
change [a v] by (number)
report (a) :: control cap
[/scratchblocks]
now the block in action:
[scratchblocks]
script variables (ff) @delInput @addInput:: grey
set [ff v] to (10)
report (change [ff v] by (10) :: variables) :: control cap[/scratchblocks] would report 20
This is the most officially approved version -- it's more or less why Jens invented block variables -- but it has a particular variable built in. The original question was how to make a block that takes the variable as input. So I think @ego-lay_atman-bay's solution is best.
Oops,. no, I quoted the right one but was looking at the other one when writing the comment. :blush: Even better, just using the regular Snap! capabilities.
Thanks to everybody who gave me answers. This was the one I used. That was very nice of you. I like your user name. . I like the Lego Batman movie too.