# SScriptingRuntime

**Membres** 10

|           |                                           |                                                           |
| --------- | ----------------------------------------- | --------------------------------------------------------- |
| Fonction  | [GetResource](#getresource)               | Get the resource by its name and return it.               |
| Fonction  | [CallScriptFunction](#callscriptfunction) | Call registered script function with specified arguments. |
| Fonction  | [Reset](#reset)                           | Reset event members to their initial values.              |
| Fonction  | [GetPublicVariable](#getpublicvariable)   | Gets the public variable by its name and return it.       |
| Fonction  | [SetPublicVariable](#setpublicvariable)   | Set the property to public variable with name "name".     |
| Fonction  | [InvokeEvent](#invokeevent)               | Invokes the event with the name "name".                   |
| Propriété | [Resources](#resources)                   | Return a list of resource.                                |
| Propriété | [Enabled](#enabled)                       | Whether the scripting runtime component is Enabled.       |
| Propriété | [ComponentName](#componentname)           | The name of this component.                               |
| Propriété | [GameObject](#gameobject)                 | –                                                         |

## Fonctions

### GetResource

[SResource](/docs/fr/scripting/client-scripting-api-reference/types/sresource.md) GetResource(string name)

Get the resource by its name and return it.

Paramètres

| Nom  | Type   | Valeur par défaut |
| ---- | ------ | ----------------- |
| name | string | –                 |

Valeurs de retour

`SResource`

Exemple

**Lua**

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

```

### CallScriptFunction

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

void CallScriptFunction(string name)

Call registered script function with specified arguments.

Paramètres

| Nom       | Type               | Valeur par défaut |
| --------- | ------------------ | ----------------- |
| name      | string             | –                 |
| arguments | params DynValue\[] | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

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

```

### Reset

void Reset()

Reset event members to their initial values.

Valeurs de retour

`void`

Exemple

**Lua**

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

```

### GetPublicVariable

object GetPublicVariable(string name)

Gets the public variable by its name and return it.

Paramètres

| Nom  | Type   | Valeur par défaut |
| ---- | ------ | ----------------- |
| name | string | –                 |

Valeurs de retour

`object`

Exemple

**Lua**

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

```

### SetPublicVariable

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

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

Paramètres

| Nom        | Type     | Valeur par défaut |
| ---------- | -------- | ----------------- |
| name       | string   | –                 |
| property   | DynValue | –                 |
| persistent | bool     | false             |

Valeurs de retour

`void`

Exemple

**Lua**

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

```

### InvokeEvent

void InvokeEvent(string name)

Invokes the event with the name "name".

Paramètres

| Nom  | Type   | Valeur par défaut |
| ---- | ------ | ----------------- |
| name | string | –                 |

Valeurs de retour

`void`

Exemple

**Lua**

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

```

## Propriétés

### Resources

[SResource](/docs/fr/scripting/client-scripting-api-reference/types/sresource.md)\[] Resources {get; }

Return a list of resource.

Exemple

**Lua**

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

```

### Enabled

bool Enabled {get; set; }

Whether the scripting runtime component is Enabled.

Exemple

**Lua**

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

```

### ComponentName

string ComponentName {get; }

The name of this component.

Exemple

**Lua**

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

```

### GameObject

[SGameObject](/docs/fr/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

Exemple

**Lua**

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

```
