Set Reference

From Fancade Wiki
Set Reference
Set Reference number.png
TypeScript block
ColliderNone
Ports
Inputs Before
Variable
Value
Outputs After

Like Set Variable, but with an additional input for the variable to store the value in. This enables you to store a variable in a List by connecting List Element to the Variable port, or make custom script blocks that modify variables.

In the early days of Fancade, this was the only way to set a variable's value.

Setting a variable value with Set Reference.

Example

You can find an example of making lists in the List page. This page will focus on another use.

We will recreate the Increase Number block (by using a script block):

One input port, which is added by 1.

This script block takes a variable, either by Get Variable or List Element. We have the increased number, now we have to set that value to the input variable, but how?

Set Variable cannot work in this case as it can only modify the variable as deemed by the user for the entire duration. And worse, it is by default local and so the variable we would like to increment remains unchanged. Other variable modes are impractical as well.

Therefore, we will have to use a more versatile script block. Set Reference allows to modify the variable on the left-hand side as named by the user:

The final script.

Related