What to use for temporary variables?

manu5

  • Posts: 27
"function" level variables are something I've been wanting to put into Stencyl for quite some time, but I haven't though of an elegant, non-error prone (for the end user) and not-too-complicated way of doing this yet.

The best solution I've thought of is to introduce a new wrapper block that lets you define a variable within that and drag the variable out of the block (a la custom blocks) to clone/use it, but this is fraught with all sorts of issues we'd have to anticipate.

What about a custom block, where you can als specify local variables, not just parameters for the custom block? And these local variables are displayed on the right side of the header just like collision event wrappers where actors can be referenced this way. And attribute setters could be used to set their value. But we need a much less painful way to modify custom block headers whitout creating a new one to make it usable.

dripple

  • Posts: 748
...into Stencyl to solve this function level variables issue.
I wouldn't call it an issue. I would say "a feature that would make programmer feel more comfy" :)
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

dripple

  • Posts: 748
What about a custom block, where you can als specify local variables,
Just place the custom block into a separate behavior, so the attributes are only visible in this behavior, that's it.
You can access this block from everywhere, in every other behavior.
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

manu5

  • Posts: 27
I meant a new feature, a changed custom block feature, where you can specify (any number of) local variables for the custom block and use them the same way as actors in collision blocks. I do not like the idea of creating a separate behavior for every custom block with function level variables. And I am not sure if it is faster or more comfortable than using attributes in the same behavior.

gamegirlxl

  • Posts: 716
What about a custom block, where you can als specify local variables, not just parameters for the custom block? And these local variables are displayed on the right side of the header just like collision event wrappers where actors can be referenced this way. And attribute setters could be used to set their value. But we need a much less painful way to modify custom block headers whitout creating a new one to make it usable.

I thought of something after reading this.  It would be really helpful to be able to grab a custom function block from the left side, where it is defined.  You can use custom functions especially well to return constants, and if you declare a variable in real text code, you can use them to retrieve it.