SShared
ServerNetwork
On this classSetGlobal
Members 7
| Function | SetGlobal | Sets a global key to a value. |
| Function | GetGlobal | Retrieves a previously set global variable, or returns nil. |
| Function | RegisterFunction | Makes func into a global function that can be accessed anywhere. |
| Function | RegisterBroadcastFunction | Makes func into a global function that can be accessed anywhere. |
| Function | UnregisterBroadcastFunction | Unregister Broadcast Function. |
| Function | CallFunction | Calls the registered function with the specified arguments. |
| Function | CallBroadcastFunction | Calls every registered broadcast function with the specified arguments, and returns the number of calls queued. |
Functions
SetGlobal
void SetGlobal(string ns, string key, DynValue value)
Sets a global key to a value. The value can be any object type.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| key | string | – |
| value | DynValue | – |
Returns
void
Example
Lua
Space.Shared.SetGlobal("com.someNameHere.world", "version", "1.02");
GetGlobal
DynValue GetGlobal(string ns, string key)
Retrieves a previously set global variable, or returns nil.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| key | string | – |
Returns
DynValue
Example
Lua
local versionValue = Space.Shared.GetGlobal("com.someNameHere.world", "version")
RegisterFunction
void RegisterFunction(string ns, string func, Closure reference)
Makes func into a global function that can be accessed anywhere.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| func | string | – |
| reference | Closure | – |
Returns
void
Example
Lua
function someFunction(name)
Space.Log("Hello " .. name);
end
Space.Shared.RegisterFunction("com.someNameHere.world", "func", someFunction);
RegisterBroadcastFunction
void RegisterBroadcastFunction(string ns, string func, Closure reference)
Makes func into a global function that can be accessed anywhere.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| func | string | – |
| reference | Closure | – |
Returns
void
Example
Lua
function someFunction(name)
Space.Log("Hello " .. name);
end
Space.Shared.RegisterBroadcastFunction("com.someNameHere.world", "func", someFunction);
UnregisterBroadcastFunction
void UnregisterBroadcastFunction(string ns, string func, Closure reference)
void UnregisterBroadcastFunction(string ns, string func)
Unregister Broadcast Function.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| func | string | – |
| reference | Closure | – |
Returns
void
Example
Lua
example 1
CallFunction
void CallFunction(string ns, string func, IEnumerable< DynValue > args)
Calls the registered function with the specified arguments.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| func | string | – |
| args | IEnumerable< DynValue > | – |
Returns
void
Example
Lua
Space.Shared.CallFunction("com.someNameHere.world", "func",{"Smith"});
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.
Parameters
| Name | Type | Default |
|---|---|---|
| ns | string | – |
| func | string | – |
| args | IEnumerable< DynValue > | – |
Returns
int
Example
Lua
example 1



