This guide is about variables. It will teach you when to use them, how to use them, and why to use them. Pictures coming later!
What Are Variables And How Do You Make Them?
Variables are exclusive to block coding. They are located in the variables menu (obviously). When you first open that menu up, you don’t see any variables! Why is that? Well, you must first create a variable. To create a variable, click on the create a variable button, and type your variable’s name in. Now, the blocks for variables should appear. Now you are ready to use them.
How Do I Use Them?
So the set block, sets the variable to anything. The variable can store text, numbers, or true and false values (boolean values). When using more than one variable, there is a dropdown at the variable’s name, so you can pick your variable. Also, do not use get property with a variable! This will cause all sorts of problems!
The change by [insert number] block increases the variable by your specified number. Lastly, you have the individual variable. This is used when doing stuff (this can be literally anything!) with the variable, like energy*10. So now you know how to use variables!
When Do I Use Them?
Properties are variables’ main rivals. They are usually better than variables, however. Properties save outside of the specific time the block code runs, but variables don’t save in between 2 block codes running. This is HUGE. In regular old computations, variables would be better than they are now, but in games, we kind of need them to save outside of the block code. (This guide is sort of my anti-variable psa.) The main advantage of variables is that they don’t need a get property block to work, so whenever you use them, variables save a block. So, you should use variables whenever you have to use the same property 6 or more times (correct me if I’m wrong).
In conclusion, variables are pretty cool, but they are overshadowed by properties.