-
Notifications
You must be signed in to change notification settings - Fork 154
API Reference
The greenworks
module gives you ability to access Steam APIs, a simple example:
var greenworks = require('./greenworks-osx');
if (greenworks.initAPI()) {
console.log('Steam API has been initalized.');
} else {
console.log('Error on initializing Steam API');
}
##References
###Greenworks.initAPI()
Returns a Boolean
whether Steam APIs were successfully initialized or not.
Note: You need to launch and log in the Steam Client, and put steam_appid.txt
under your app directory.
###Greenworks.getSteamId()
Returns an 'Object' represents extensive information of the current Steam user.
- Result
Object
- accountId
Integer
: Steam account ID - staticAccountId
Integer
: Static steam ID - screenName
String
: Steam screen name - level
Integer
: Steam level - isValid
Boolean
: whether is a valid account - type
Object
: represents user account type- name
String
: User account type name - value
Integer
: User account type id
- name
- flags
Object
: represents describing types of user account information- anonymous
Boolean
: whether is an anonymous account - anonymousGameServer
Boolean
: whether is an anonymous game server account - anonymousGameServerLogin
Boolean
: whether is an anonymous game server account login request - anonymousUser
Boolean
: whether is an anonymous user account - chat
Boolean
: whether is a chat account - clan
Boolean
: whether is a clan account - consoleUser
Boolean
: whether is a console user(PSN) account - contentServer
Boolean
: whether is a content server account - gameServer
Boolean
: whether is a game server account - individual
Boolean
: whether is a individual account - gameServerPersistent
Boolean
: whether is a persistent game server account - lobby
Boolean
: whether is a lobby(chat) account
- anonymous
- accountId
###Greenworks.saveTextFoFile(file_name, file_content, success_callback, error_callback)
-
file_name
String -
file_content
String -
success_callback
Function() -
error_callback
Function(err)
###Greenworks.readTextFromFile(file_name, success_callback, error_callback)
-
file_name
String -
success_callback
Function(file_content)-
file_content
String: represents the content offile_name
file.
-
-
error_callback
Function(err)
###Greenworks.isCloudEnabled()
Returns a Boolean
indicates whether cloud is enabled for the current app.
###Greenworks.enableCloud(flag)
-
flag
Boolean
Enables/Disables the cloud feature for the current app.
###Greenworks.getCloudQuota(success_callback, error_callback)
-
success_callback
Function(total_bytes, available_bytes)-
total_bytes
Integer: total bytes of quota -
available_bytes
Integer: available bytes of quota
-
-
error_callback
Function(err)
###Greenworks.activateAchievement(achievement, success_callback, error_callback)
-
achievement
String -
success_callback
Function() -
error_callback
Function(err)
The achievement
represents the unlocked achievement in your game.
###Greenworks.getCurrentGameLanguage()
Returns a String
represents the current language from Steam specifically set for the game.
###Greenworks.getCurrentUILanguage()
Returns a String
represents the current language from Steam set in UI.
###Greenworks.getCurrentGameInstallDir()
Not implement yet.
###Greenworks.getNumberOfPlayers(success_callback, error_callback)
-
success_callback
Function(num_of_players)-
num_of_players
Integer: the current number of players on Steam.
-
-
error_callback
Function(err)
The API has 2s timeout restriction since Steam API callback is not invoked each time. If greenworks doesn't get the result in 2s, it will call the error_callback
.