To setup your server for communication with space, in the root of your domain, on the port you are using, place a file named 'sinewave.space.scripting.txt' containing 'SPACE_OK'. E.g. http://somewhere.com/sinewave.space.scripting.txt - if this file is not present, you will be unable to use scripting to communicate with the domain. Note: you should use HTTPS for all API calls if you want these to work reliably in WebGL. You may also need to implement a CORS policy in your webserver headers.
Index
Functions Index
Function Name
Functions
Get
void Get (string url, Closure onComplete, Table headers=null, float timeout=0)
Performs a HTTP[S] GET against URL and returns the contents as a SWebResponse
--For example, you want to get a game data from your domainlocal userID ="AvatarID" --You can using Space.Scene.PlayerAvatar to get the current player's infolocal gameID ="GameID" --Just an example, like you have more than one game hostedlocal sentData ="http://www.yourdomain.net/getGameData.php?id=" .. userID .."&game=" .. gameIDlocalresponse=function(data)if data.Error ==nilthen Space.Log(data.Response)else Space.Log(data.Error)endendSpace.WebServices.Get(sentData, response)--Phase the response to get what you need
local userID ="AvatarID"local gameID ="GameID"local url ="http://www.yourdomain.net/getGameData.php"local sentData ="id=" .. userID .."&game=" .. gameIDlocalresponse=function(data)if data.Error ==nilthen Space.Log(data.Response)else Space.Log(data.Error)endendSpace.WebServices.Post(url, sentData, response)-- Like the example above, just using http(s) post method.
Returns a valid SResource for a image on a remote domain that can be used via e.g. SMaterial. While the image loads, it will be a white pixel that will be substituted with the real image once loaded.