Using Variables in StudyCrafter​

1. Use Variables for Display

In any part of the game where text is displayed, you can display the value of any variable to players by using the format {Variable Name} in the texts. You can display variable values in various nodes involving text, such as Dialogue Node and Player Choice Node. Additionally, you can show variable values on objects with text by setting the ‘text’ object variable. For example, if there is a variable named ‘money’ with a value of 30, you can display this in a dialogue by setting the ‘Dialogue’ field of the Dialogue Node to “Now you have {money}$.” (For more information about the Dialogue Node, see “Dialogue Node” in Onboarding.)

Figure 1. A dialogue node that displays the money that the player has.

2. Use Variables for Dynamic Flow Control

Variables with the correct value type can be used to substitute values in different nodes. You can use variables to dynamically control the behavior of nodes. For instance, as shown in Figure 2, float variables can be used to substitute the “X-Position”, “Y-Position”, and “Duration” values in the “Move To” function in the Action Node. Instead of directly inputting numbers as values, using variables allows you to adapt the movement of the “famale_construction_1” to different situations in the game. (For more information about how to use different nodes, see “Nodes” in Onboarding)

Figure 2. Three float type scripting variables, “famale_posx”, “famale_posy”, and “move_time”, are used to substitute numbers in the Action Node.

Besides, variables can be used in the Branch Node for the logic control. For more information, please see “Branch Node” in Onboarding.

3. Set and Change the Value of Variables

To set and modify variable values, you can use the Variable tab to establish initial values, the Set Variable Node, or the Player Choice Node. Detailed instructions for their use can be found on their respective pages.