Sinespace Scripting Documentation
This documentation is in progress. Please visit this page to report any issues, missing information, corrections or suggestions you may have.
Scripting in Sinespace uses the Lua programming language.
Sinespace offers scripters Unity components, which are added to GameObjects, that will run the scripts(code) that we write inside them.
These Unity components come within the Sinespace Editor Pack package, which needs to be installed in our Unity project before we begin scripting.
Our core class is the SScript class, which is accessed by writing "Space".
Example: Space.Log('Hello World')
is equivalent to SScript.Log('Hello world').
All of your functions/properties will be accessed starting with 'Space' which also navigates to other classes. There's very few exceptions that are accessed directly such as "Math" (SMath) and "Color"(SColor).
Example: Space.Network.SendNetworkMessage()
this starts with the SScript class and goes into the SNetwork class.
Client scripts run client-side, and Server scripts run server-side.
Browsing the left panel of this documentation you will find that our API Reference is split into two different parts - Client Scripting and Server Scripting.
To begin creating your first Sinespace Client Script, make sure you have the Sinespace Editor Pack properly installed, and then:
Select your GameObject
Click Add Component
Search for and select Scripting Runtime
Enter your code in the Script Contents text box - for example Space.Log('Hello World!')
Press Play Scene (you should see your "Hello World!" in the Unity console window)
It's recommended that new scripters familiarize themselves with Client scripts first before jumping into Server scripts, or creating more complicated objects that require server scripts.
Visit the Server Scripts guide to begin your first Server script.
Opens a color picker dialogue.
void ColorPicker(string title, string okbutton, Action< SColor > onChange, Action< SColor > onSelect, Action onCancel, SColor defaultColor)
title
string
The title of the color picker window. Choose something brief and appropriate like 'Select a wall color'.
okbutton
string
The title of the 'OK' button. Should indicate the action e.g. 'Adjust Wall'.
onChange
Action<SColor> or Closure
Any color change while the color picker is open will trigger onChange(SColor).
onSelect
Action<SColor> or Closure
Triggers onSelect(SColor) once the "ok" button is pressed.
onCancel
Action<SColor> or Closure
The title of the 'OK' button. Should indicate the action e.g. 'Adjust Wall'.
defaultColor
SColor
The color to open the colour picker with.
Opens a simple Yes/No dialogue.
void YesNoInput(string title, string okbutton, string cancelButton, Action< bool > result)
title
string
The question to be asked of the user. Should be a simple statement, e.g. "Save room changes?"
okbutton
string
The text on the OK button, should indicate the action, e.g. "Save Room"
cancelButton
string
The text on the cancel button, should indicate the action, e.g. "Not now"
result
Action<bool>
Will fire a callback event depending on the status of the users actions
Opens a text entry window with room for a single multi-line text field.
void TextInput ( string title, string okButton, Action< string > result)
title
string
The accompanying text. Should be something ala "Enter your username".
okButton
string
The text displayed on the OK button, should be descriptive, e.g. "Change Username".
result
Action< string >
Triggers result(string) once the "Ok" button is pressed.
Opens the specified URL in the in-app web browser, or the system web browser. In some environments the user may be prompted before this is opened.
void OpenURL ( string url, bool newTab = true )
url
string
The web address to open.
newTab
bool
Does the URL open in a new browser tab?
Sends a message into the 'Script' chat channel.
void SendLocalChat ( string message, string from )
message
string
The message to appear in the channel.
from
string
The 'from' username for the message.
Loading...
void SetGlobal(string ns, string key, DynValue value)
Sets a global key to a value. The value can be any object type.
ns
string
key
string
value
DynValue
void SetSuperGlobal(string ns, string key, DynValue value)
Function Description
DynValue GetGlobal(string ns, string key)
Retrieves a previously set global variable, or returns nil.
DynValue GetSuperGlobal(string ns, string key)
Retrieves a previously set super global variable, or returns nil.
void RegisterFunction(string ns, string func, Closure reference)
Makes func into a global function that can be accessed anywhere.
void RegisterBroadcastFunction(string ns, string func, Closure reference)
Makes func into a global function that can be accessed anywhere.
void UnregisterBroadcastFunction(string ns, string func, Closure reference) void UnregisterBroadcastFunction(string ns, string func)
Function Description
void CallFunction(string ns, string func, IEnumerable< DynValue > args)
Calls the registered function with the specified arguments.
void CallBroadcastFunction(string ns, string func, IEnumerable< DynValue > args)
Makes func into a global function that can be accessed anywhere.
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
void (string title, string okbutton, Action< SColor > onChange, Action< SColor > onSelect, Action onCancel, SColor defaultColor)
void (string title, string okbutton, string cancelButton, Action< bool > result)
void (string title, string okButton, Action< string > result)
void (string url, bool newTab = true)
void (string message, string from)
void (string ns, string key, DynValue value)
void (string ns, string key, DynValue value)
DynValue (string ns, string key)
DynValue (string ns, string key)
void (string ns, string func, Closure reference)
void (string ns, string func, Closure reference)
void (string ns, string func, Closure reference)
void (string ns, string func)
void (string ns, string func, IEnumerable< DynValue > args)
void (string ns, string func, IEnumerable< DynValue > args)