Username:
Password:
Login Register Password Lost

Storage API

The game engine API contains a special API allowing developers to store and retrieve data across multiple players. This API acts nearly like an usual SQL database and can be called from any game script.

The following functions are currently available:
To create a new table and store data within:
Storage.AddNewData("myTest", "User", "Alain");
Storage.AddNewData("myTest", "Score", "10");
Storage.StoreData("myTest");
The table will be created automatically the first time you try to write something to it.

To modify some data:
Storage.Update("myTest", "Score", newValue, "User = ?","Alain");

To delete some data:
Storage.Delete("myTest", "User = ?","Alain");

To read some data:
var q=Storage.QueryData("myTest");
Storage.Where(q, "User = ?","Alain");
Storage.ExecuteQuery(q);
var html="";
while(Storage.NextRow(q))
{
    html+=Storage.GetValue(q, "user")+": ";
    html+=Storage.GetValue(q, "score");
    html+="\n";
}    
Storage.CloseQuery(q);

The conditions used within the select where, update and delete accept the following operations:

=The column and the value must be the same.
<>The column and the value must be different.
containsThe column must contains the value.
not containsThe column must not contains the value.
startsThe column must starts with the value.
endsThe column must ends with the value.
emptyThe column must be empty.
not emptyThe column must not be empty.
<The column must be smaller than the value.
<=The column must be smaller or equal than the value.
>=The column must be bigger or equal than the value.
>The column must be bigger than the value.
All checks are case insensitive.

Multiple conditions can be joined with the "and" / "or" operators. To specify an order of precedence, the round brackets can be used.

It is possible to retrieve all the tables stored:
Storage.retrieveTableList();
var html="";
for(var i=0;i < Storage.NBTables();i++)
{
    html+=Storage.GetTableName(i)+"\n";
}
Display.SetDialogText(html);

And retrieve all the columns of a given table:
Storage.RetrieveColumnList("myTest");
var html="";
for(var i=0;i < Storage.NBColumns();i++)
{
    html+=Storage.GetColumnName(i)+"\n";
}
Display.SetDialogText(html);

Check if a table exists:
function CheckTableExists()
{
    if(Storage.TableExists("myTest"))
        Display.Log("Table exists");
    else
        Display.Log("Table doesn't exist");
}

© 2016 - 2017 - A. Bertrand - Terms & conditions