# SShared

## Index

### Functions Index

| Function                                                                                                                                                                                                                      |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| void [**SetGlobal** ](#setglobal)(string ns, string key, DynValue value)                                                                                                                                                      |
| DynValue [**GetGlobal** ](#getglobal)(string ns, string key)                                                                                                                                                                  |
| void [**RegisterFunction** ](#registerfunction)(string ns, string func, Closure reference)                                                                                                                                    |
| void [**RegisterBroadcastFunction** ](#registerbroadcastfunction)(string ns, string func, Closure reference)                                                                                                                  |
| <p>void <a href="#unregisterbroadcastfunction"><strong>UnregisterBroadcastFunction</strong> </a>(string ns, string func, Closure reference)<br>void <strong>UnregisterBroadcastFunction</strong> (string ns, string func)</p> |
| void [**CallFunction** ](#callfunction)(string ns, string func, IEnumerable< DynValue > args)                                                                                                                                 |
| int [**CallBroadcastFunction** ](#callbroadcastfunction)(string ns, string func, IEnumerable< DynValue > args)                                                                                                                |

## Functions

### SetGlobal

void **SetGlobal** (string ns, string key, DynValue value)

*Sets a global key to a value. The value can be any object type.*

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

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

```lua
Space.Shared.SetGlobal("com.someNameHere.world", "version", "1.02");
```

{% endtab %}
{% endtabs %}

### GetGlobal

DynValue **GetGlobal** (string ns, string key)

*Retrieves a previously set global variable, or returns nil.*

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

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

```lua
local versionValue = Space.Shared.GetGlobal("com.someNameHere.world", "version")
```

{% endtab %}
{% endtabs %}

### RegisterFunction

void **RegisterFunction** (string ns, string func, Closure reference)

*Makes func into a global function that can be accessed anywhere.*

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

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

```lua
function someFunction(name)
  Space.Log("Hello " .. name);
end

Space.Shared.RegisterFunction("com.someNameHere.world", "func", someFunction);
```

{% endtab %}
{% endtabs %}

### RegisterBroadcastFunction

void **RegisterBroadcastFunction** (string ns, string func, Closure reference)

*Makes func into a global function that can be accessed anywhere.*

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

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

```lua
function someFunction(name)
  Space.Log("Hello " .. name);
end

Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
```

{% endtab %}
{% endtabs %}

### UnregisterBroadcastFunction

void **UnregisterBroadcastFunction** (string ns, string func, Closure reference)\
void **UnregisterBroadcastFunction** (string ns, string func)

*Unregister Broadcast Function.*

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

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

```lua
example 1
```

{% endtab %}
{% endtabs %}

### CallFunction

void **CallFunction** (string ns, string func, IEnumerable< DynValue > args)

*Calls the registered function with the specified arguments.*

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

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

```lua
Space.Shared.CallFunction("com.someNameHere.world", "func",{"Smith"});
```

{% endtab %}
{% endtabs %}

### CallBroadcastFunction

int **CallBroadcastFunction** (string ns, string func, IEnumerable< DynValue > args)

*Calls every registered broadcast function with the specified arguments, and returns the number of calls queued.*

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

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

```lua
example 1
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sine.space/scripting/server-scripting-api-reference/network/sshared.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
