# SScriptingData

## Index

### Functions Index

| Function Name                                                                                |
| -------------------------------------------------------------------------------------------- |
| object [**GetVariable** ](#getvariable)(string name)                                         |
| void [**SetVariable** ](#setvariable)(string name, DynValue property, bool persistent=false) |

### Properties Index

| Property Name                                    |
| ------------------------------------------------ |
| bool [**Enabled** ](#enabled)`get` `set`         |
| string\[] [**Variables** ](#variables)`get`      |
| string [**ComponentName**](#componentname) `get` |
| SGameObject [**GameObject** ](#gameobject)`get`  |

## Functions

### GetVariable

object **GetVariable** (string name)

*Return the object of the variable.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.Data.GetVariable("variableName")
```

{% endtab %}
{% endtabs %}

### SetVariable

void **SetVariable** (string name, DynValue property, bool persistent=false)

*Set properties to variable.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.SetVariable("variableName",5,true)
```

{% endtab %}
{% endtabs %}

## Properties

### Enabled

bool **Enabled** `get` `set`

*Is the ScriptingData component Enabled?*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.Data.Enabled = false
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object will Enable/Disable it's Scripting Data component
thisGameObject = Space.Host.ExecutingObject
component = thisGameObject.Data

OnClick = function()
component.Enabled =  not component.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
```

{% endtab %}
{% endtabs %}

### Variables

string\[] **Variables** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
variableNames = Space.Host.ExecutingObject.Data.Variables
```

{% endtab %}
{% endtabs %}

### ComponentName

string **ComponentName** `get`

*The name of this component.*

{% tabs %}
{% tab title="Lua" %}

```lua
componentName = Space.Host.ExecutingObject.Data.ComponentName
```

{% endtab %}
{% endtabs %}

### GameObject

[SGameObject](https://docs.breakroom.tech/scripting/client-scripting-api-reference/types/sgameobject) **GameObject** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
theGameObject = Space.Host.ExecutingObject.Data.GameObject
```

{% endtab %}
{% endtabs %}
