# SScriptingRuntime

## Index

### Functions Index

| Function Name                                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| SResource [**GetResource** ](#getresource)(string name)                                                                                                                                                                   |
| <p>void <a href="#callscriptfunction"><strong>CallScriptFunction</strong> </a>(string name, params DynValue\[] arguments)<br>void <a href="#callscriptfunction"><strong>CallScriptFunction</strong> </a>(string name)</p> |
| void [**Reset** ](#reset)()                                                                                                                                                                                               |
| object [**GetPublicVariable** ](#getpublicvariable)(string name)                                                                                                                                                          |
| void [**SetPublicVariable** ](#setpublicvariable)(string name, DynValue property, bool persistent=false)                                                                                                                  |
| void [**InvokeEvent** ](#invokeevent)(string name)                                                                                                                                                                        |

### Properties Index

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

## Functions

### GetResource

[SResource](https://docs.breakroom.tech/scripting/client-scripting-api-reference/types/sresource) **GetResource** (string name)

*Get the resource by its name and return it.*

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

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

```lua
resource = Space.Host.ExecutingObject.Script.GetResource("resource name")
```

{% endtab %}
{% endtabs %}

### CallScriptFunction

void **CallScriptFunction** (string name, params DynValue\[] arguments)\
void **CallScriptFunction** (string name)

*Call registered script function with specified arguments.*

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

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

```lua
resource = Space.Host.ExecutingObject.Script.CallScriptFunction("FunctionName")
--or
resource = Space.Host.ExecutingObject.Script.CallScriptFunction("FunctionName", tableWithArguments)
```

{% endtab %}
{% endtabs %}

### Reset

void **Reset** ()

*Reset event members to their initial values.*

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

```lua
Space.Host.ExecutingObject.Script.Reset()
```

{% endtab %}
{% endtabs %}

### GetPublicVariable

object **GetPublicVariable** (string name)

*Gets the public variable by its name and return it.*

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

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

```lua
publicVariable = Space.Host.ExecutingObject.Script.GetPublicVariable("variableName")
```

{% endtab %}
{% endtabs %}

### SetPublicVariable

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

*Set the property to public variable with name "name".*

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

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

```lua
Space.Host.ExecutingObject.Script.SetPublicVariable("VariableName",5,true)
```

{% endtab %}
{% endtabs %}

### InvokeEvent

void **InvokeEvent** (string name)

*Invokes the event with the name "name".*

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

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

```lua
Space.Host.ExecutingObject.Script.InvokeEvent("EventName")
```

{% endtab %}
{% endtabs %}

## Properties

### Resources

[SResource](https://docs.breakroom.tech/scripting/client-scripting-api-reference/types/sresource)\[] **Resources** `get`

*Return a list of resource.*

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

```lua
tableResources = Space.Host.ExecutingObject.Script.Resources
```

{% endtab %}
{% endtabs %}

### Enabled

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

*Whether the scripting runtime component is Enabled.*

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

```lua
Space.Host.ExecutingObject.Script.Enabled = true
```

{% endtab %}
{% endtabs %}

### ComponentName

string **ComponentName** `get`

*The name of this component.*

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

```lua
componentName = Space.Host.ExecutingObject.Script.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.Script.GameObject
```

{% endtab %}
{% endtabs %}
