liamcottle / rustplus.js

Unofficial NodeJS library for controlling Smart Switches in the PC game Rust
232 stars 47 forks source link

Steamdeck API call implementation possibility #10

Closed Thetechnopig closed 3 years ago

Thetechnopig commented 3 years ago

Just wondering if I would be able to make http call requests to the server through api linked buttons on a configured streamdeck panel

liamcottle commented 3 years ago

Just had a quick look, and there's a NodeJS library for the stream deck. https://www.npmjs.com/package/elgato-stream-deck You should be able to hook up something pretty easy with both libraries. Anything in particular you'd be wanting to achieve?

Thetechnopig commented 3 years ago

It looks to be fully redeveloping your code into a stream deck plugin

On Mon., Jan. 4, 2021, 11:16 p.m. Liam Cottle, notifications@github.com wrote:

Just had a quick look, and there's a NodeJS library for the stream deck. https://www.npmjs.com/package/elgato-stream-deck You should be able to hook up something pretty easy with both libraries.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liamcottle/rustplus-api/issues/10#issuecomment-754382038, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKORG64FF6OPDEXRN5K3JTSYKHARANCNFSM4VRWEFDQ .

liamcottle commented 3 years ago

Depends what you're trying to achieve. You could do something very simple like this (pseudo code). Which would open and close a door in rust when pressing a button on the stream deck.

const RustPlus = require('rustplus-api');
const { openStreamDeck } = require('elgato-stream-deck');

// connect to rust server
var rustplus = new RustPlus('hostname', 28183, 'steamid', 1234567890);

// wait until connected to rust server
rustplus.on('connected', () => {

    // connect to stream deck
    const myStreamDeck = openStreamDeck();

    // callback when button is pressed on stream deck
    myStreamDeck.on('up', (keyIndex) => {

        // check what button was pressed on stream deck
        if(keyIndex == 'some-button'){
            rustplus.turnSmartSwitchOn(1234567890); // open door (via smart switch)
        } else if(keyIndex == 'some-other-button') {
            rustplus.turnSmartSwitchOff(1234567890); // close door (via smart switch)
        }

    });

});