Coder Social home page Coder Social logo

goosehub / steamworks.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ceifa/steamworks.js

0.0 0.0 0.0 24.02 MB

A steamworks implementation for nw.js/electron games

License: MIT License

JavaScript 17.58% Rust 81.44% TypeScript 0.24% HTML 0.73%

steamworks.js's Introduction

Build Status npm License: MIT Chat

Steamworks.js

A modern implementation of the Steamworks SDK for HTML/JS and NodeJS based applications.

Why

I used greenworks for a long time and it's great, but I gave up for the following reasons.

  • It's not being maintained anymore.
  • It's not up to date.
  • It's not context-aware.
  • You have to build the binaries by yourself.
  • Don't have typescript definitions.
  • The API it's not trustful.
  • The API implement callbacks instead of return flags or promises.
  • I hate C++.

API

const steamworks = require('steamworks.js')

// You can pass an appId, or don't pass anything and use a steam_appid.txt file
const client = steamworks.init(480)

// Print Steam username
console.log(client.localplayer.getName())

// Tries to activate an achievement
if (client.achievement.activate('ACHIEVEMENT')) {
    // ...
}

You can refer to the declarations file to check the API support and get more detailed documentation of each function.

Installation

To use steamworks.js you don't have to build anything, just install it from npm:

$: npm i steamworks.js

For the production build, copy the relevant distro files from sdk/redistributable_bin/{YOUR_DISTRO} into the root of your build.

Electron

Steamworks.js is a native module and cannot be used by default in the renderer process. To enable the usage of native modules on the renderer process, the following configurations should be made on main.js:

const mainWindow = new BrowserWindow({
    // ...
    webPreferences: {
        // ...
        contextIsolation: false,
        nodeIntegration: true
    }
})

To make the steam overlay working, call the electronEnableSteamOverlay on the end of your main.js file:

require('steamworks.js').electronEnableSteamOverlay()

How to build

You only need to build if you are going to change something on steamworks.js code, if you are looking to just consume the library or use it in your game, refer to the installation section.

Make sure you have the latest node.js, Rust and Clang. We also need Steam installed and running.

Install dependencies with npm install and then run npm run build:debug to build the library.

There is no way to build for all targets easily. The good news is that you don't need to. You can develop and test on your current target, and open a PR. When the code is merged to main, a github action will build for all targets and publish a new version.

Testing Electron

Go to the test/electron directory. There, you can run npm install and then npm start to run the Electron app.

Click "activate overlay" to test the overlay.

steamworks.js's People

Contributors

ceifa avatar podrivo avatar dfabulich avatar lzqcn avatar headcr4sh avatar goosehub avatar aprivette avatar arthuro555 avatar james226 avatar stefftek avatar yorkzero831 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.