GetGameList
From Spheriki
Returns a list in the form of an array of all of the installed Sphere games in the user's /games directory.
Contents |
Usage
Examples
// Display info of first game found
var all_games = GetGameList();
var first_game_info = "";
if (all_games.length > 0)
{
var this_game = all_games[0];
first_game_info = "/" + this_game.directory + "/\n"
+ "Name: " + this_game.name + "\n"
+ "Author: " + this_game.author + "\n"
+ "Desc: " + this_game.description;
}
else
{
first_game_info = "No games found!";
}
Abort(first_game_info + "\n");
The above will list information about the first game found, assuming there are games present in the player's Sphere installation.
// List directories and game names
var games = GetGameList();
var list = "";
for (var i = 0; i < games.length; ++i)
{
list += "/" + games[i].directory + "\t" + games[i].name + "\n";
}
Abort(list);
The example above shows a summary of all the games found in the player's Sphere installation. If the list is long, it may not be possible to see all the entries.
Notes
This function enables the indexing of the games in the player's Sphere/games/ directory. It will not index Sphere games installed in other locations in the filesystem, nor will compressed Sphere packages (or .spk files) show up in the list.
The return value of GetGameList() is a Javascript array of Sphere Game objects. Each Game object describes one of the games found in the Sphere/games/ directory.
The directory property of a Game object can be used by ExecuteGame(directory) to actually run a chosen game. This mechanism is used by virtually all startup games.
See also
- Abort()
- Game Object
- Javascript Array
- Sphere package format (.spk)
- Sphere startup game

