onnateldome / greenworks

a node.js/node-webkit plugin to integrate with steamworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

greenworks

A node.js plugin to integrate with Steamworks. The plugin was developed to enable the Steam release of Greenheart Games' Game Dev Tycoon, a game powered by node-webkit. It has since been used by other projects.

API

For Game Dev Tycoon we've added support for several Steam related functionality, such as Workshop synchronization, Steam Cloud and Steam Achievements. The methods we used are based on the Steamworks SDK.

Greenworks

  • initAPI()
  • activateAchievement(string achievementId, func success, func error)
  • getNumberOfPlayers()
  • getCurrentGameLanguage()
  • getCurrentUILanguage()
  • getSteamId()
  • getCurrentGameInstallDir()
  • getCloudQuotas()
  • readTextFromFile(string fileName, func success, func error)
  • saveTextToFile(string fileName, string content, func success, func error)
  • enableCloud()
  • isCloudEnabled()
  • isCloudEnabledForUser()
  • ugcPublish(string fileName, string title, string description, string imageFile, func successCallback, func errorCallback, func progressCallback)
  • ugcPublishUpdate(int publishedFileId, string fileName, string title, string description, string imageFile, func successCallback, func errorCallback, func progressCallback)
  • ugcGetItems(int type, int sort, func successCallback, func errorCallback, func progressCallback)
  • ugcGetUserItems(int type, int sort, int filter, func successCallback, func errorCallback, func progressCallback)
  • ugcDownloadItem(string fileName, int hFile, string targetFolder, func successCallback, func errorCallback, func progressCallback)
  • ugcSynchronizeItems(string targetFolder, func success, func error, func progress)
  • ugcShowOverlay(optional int workshopItemId)
  • ugcUnsubscribe(int publishedFileId, func success, func error, func progress)
  • runCallbacks()

Greenworks.Utils

  • createArchive(string zipFile, string sourceDir, string password, int compressionLevel, func success, func error)
  • extractArchive(string zipFile, string targetDir, string password, func success, func error)
  • sleep(int ms)
  • getOS()
  • move(string sourceFolder, string targetFolder)
  • enableConsole()
  • disableConsole()
  • enableWriteToLog(string targetFile)
  • disableWriteToLog()

Please consult the Greenworks API documentation for more information.

Dependencies

Before building modules you need to download Steamworks SDK (https://partner.steamgames.com/). Note that the steamworks SDK libraries and docs are only usable under license from Valve. If you fork Greenworks, don't commit any of the dependencies from the steamworks SDK to a public place.

Usage

We provide compiled versions of greenworks under releases. To use the binaries you will have to copy them alongside the steam libraries and then load the module via require.

Test

Here is a simple application, which inits steam API.

var greenworks = require('./greenworks-osx');

if (greenworks.initAPI()) {
    console.log('Steam API initalised');
}
else {
	console.log('Error initalising Steam API');
}

Build

If you want to build greenworks yourself, you need first to add redistributable_bin/ (under SDK folder) to PATH (so steam_api.lib is linked while building).

Using node-gyp:

node-gyp configure --target=0.8.6
node-gyp build

Using nw-gyp:

nw-gyp configure --target=0.8.6
nw-gyp build

On 64bit editions of Windows, you might need to explicitly specifiy the architecture. You can do this by adding the option --arch=ia32 to the configure line.

nw-gyp configure --target=0.8.6 --arch=ia32

If everything goes fine, it will create a folder deploy/ with node module within (greenworks-X.node, where X depends on your os. E.g. for mac it will be greenworks-osx.node). Now it's possible to use the module from a node.js application. Make sure libsteam_api dynamic library is distributed along with the application.

Troubleshooting

Possible issues while building/running:

* Library not loaded: @loader_path/libsteam_api.dylib (or .dll for windows)

That means you didn't copy this file to your app directory and it can't link it at runtime.

* SteamAPI_Init() failed; unable to locate a running instance of Steam, or a local steamclient.dll

Your steam client should be running (or you can copy the steamclient dynamic library into your app directory).

* SteamAPI_Init() failed; no appID found.

Steam can't determine for which steam application you are trying to initialise the API. Either launch the game from Steam, or put the file steam_appid.txt containing the correct appID in your app folder. steam_appid.txt should contain just your application id, nothing else.

License

Greenworks is published under the MIT license. See LICENSE file for details.

Help us improve!

Greenworks was developed to enable a minimum set of features for the Game Dev Tycoon release and could surely use more development. If you improve the project please consider opening a pull-request.

About

a node.js/node-webkit plugin to integrate with steamworks

License:MIT License