Object Variables

1. Introduction

In StudyCrafter, “Object Variables” refer to the built-in variables that define the attributes of all objects within the game. These variables can be adjusted in Layers prior to the game’s start and can also be modified dynamically during gameplay through scripts. Essentially, these variables serve as customizable attributes that dictate how objects behave and interact within the game environment.

2. Properties

  • Variable Name: Each object variable has a unique, predefined name. To use the object variable, you must input the correct name of that variable. The name of each object variable consists of two parts: the object name and the property name. For example, ‘female_1.width’ stores the width information of the ‘female_1’ object in the layout tab.
  • Variable Type: The type of the object variables describes the different attributes of the object. While objects in StudyCrafter share some object variable types, some objects have unique object variable types. These unique variable types are marked with an asterisk (*).
    • posx (Float): The x position of the object in the 2-dimensional layout. The range of ‘pox’ that makes objects visible in the layout spans from -480 (left) to 480 (right), with the center being 0. See also Minimap.
    • posy (Float): The y position of the object in the 2-dimensional layout. The range of ‘poy’ that makes objects visible in the layout spans from -270 (bottom) to 270 (top), with the center being 0. See also Minimap.
    • width (Float): The width of the object. Set width value to negative numbers will flip the object left and right.
    • height (Float): The height of the object. Set height value to negative numbers will flip the object up and down.
    • rotation (Float): The rotation of the object (measured in degrees). Setting the rotation value to positive numbers will rotate the object clockwise, while negative numbers will rotate it counterclockwise.
    • visible (Boolean): The visibility of the object in the game (True: the object can be seen; False: the object cannot be seen).
    • parent (gameObject): under construction.
    • image: The image used for the object. The object’s name is usually the same as the image name. We do not recommend changing this variable. To change the image, you must use the correct name of the image available in StudyCrafter. For a detailed list of the assets we have, please see also Built-in Assets.
    • color (Integer): The color of the object (stored in Hex numbers, see color picker). 
    • text* (String): The text on the object. Only button and text objects in Interface (advanced) have this type of variable (see also Objects in StudyCrafter).
    • textcolor* (Integer): The color of the text (stored in Hex numbers, see color picker). 
    • fontsize* (Float): The size of the text.
    • value* (Float): The value of the slide bar. Only the slide bar has this type of variable (see also Objects in StudyCrafter). It controls the length ratio of the slider within the bar, which can range from 0 to 100.

                              3. Using Object Variables

                              To use the object variables, please see “Using Variables in StudyCrafter” in Onboarding.

                              4. Q&Aa

                              How can I change the color of the object?

                              In the Layout tab, single-click to select the object, then click in the top right to open the Layers tab. Click to view the object’s detailed attributes and locate the color attributes. Use the color picker to select your desired color, then copy and paste the code to update the color attributes and change the object’s color.

                              How can I change the color/size/texts of the objects in real-time?

                              You can use “Set Variable” node to dynamically change the attributes of the object. Please check “Using Variables in StudyCrafter” in Onboarding.