GithubHelp home page GithubHelp logo

rbxcloud's Introduction

RbxCloud

Open Cloud API for Roblox experiences

About

RbxCloud is an open cloud API for Roblox experiences.

  • Object oriented
  • Aims to be as close to the Roblox API as possible for the following services:
    • DataStoreService
    • MessagingService
  • Promise-based
  • Support for non-JSON responses and such
  • Support for nearly all open-cloud features
    • Place publishing will come in a later update.

Installation

npm install rbxcloud

Example Usage

You can find working examples in example/general-usage.js or just read below:

Publish a message using MessagingService:

const { OpenCloud, MessagingService } = require('rbxcloud');
OpenCloud.Configure({
    MessagingService: 'API-KEY', // This is an API key for MessagingService
    UniverseId: 0, // You can get the UniverseId from the Asset explorer
});

MessagingService.PublishAsync('MyTopic', 'Hello World!').then(() => {
    console.log('Publish was a success!');
}).catch(err => {
    console.log(err);
});

Read, set, and update DataStore entry:

const { OpenCloud, DataStoreService } = require('rbxcloud');
const { DataStoreSetOptions } = DataStoreService.Objects;

OpenCloud.Configure({
    DataStoreService: 'API-KEY', // This is an API key for MessagingService
    UniverseId: 0, // You can get the UniverseId from the Asset explorer
});

const GoldStore = DataStoreService.GetDataStore('Gold');

GoldStore.GetAsync(125196014).then(([data, keyInfo]) => {
    console.log(keyInfo.DataType === JSON); // true / false
    console.log(keyInfo.CreatedTime); // UNIX Timestamp
    console.log(keyInfo.UpdatedTime); // UNIX Timestamp
    console.log(keyInfo.Version); // DataStore key version
    console.log(`The player has ${data.amount} gold!`)
});

// SetAsync the player's gold
GoldStore.SetAsync(125196014, {
    currency: 'Gold',
    amount: 100,
}).then((result) => {
    console.log('Data saved: ', result);
}).catch((err) => {
    console.log('Error', err);
});

// Delete the player's gold
GoldStore.RemoveAsync(125196014).then()

// Increment a player's gold (incompatible with the current data setup though)
GoldStore.IncrementAsync(125196014, 5).then(([newAmount, keyInfo]) => {
    console.log(`The player now has ${newAmount} gold!`);
}).catch((err) => {
    console.log(err);
});

// Now use UpdateAsync; has nearly the exact same functionality as the native implementation. Do not yield this.
// Additionally, if you use this with the data being an array, you will lose your data unless you wrap the array inside another array.
GoldStore.UpdateAsync(125196014, function(data, keyInfo) {
    if (data.amount < 100) {
        data += 100;
    }
    //return data; <-- This is valid
    
    // Alternatively, you can return numerous values as specified by the Roblox API for UpdateAsync:
    const metadata = {
        IsOwnedByAPlayer: true,
        IsThisPlayerVeryCool: true
    };
    return [ data, [], metadata ]
});

// UpdateAsync with an array:
GoldStore.UpdateAsync(125196014, function(data, keyInfo) {
    data.push('Hello World!');
    return [ [ data ], [], metadata ]
})

Links

Contributing

Create an issue for any suggestions or bug reports that you find. Please ensure that you've read the documentation, and if you're creating an issue, verify that it isn't a duplicate.

rbxcloud's People

Contributors

devax1t avatar littlebitsman avatar

Stargazers

Avafe avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fuglord77

rbxcloud's Issues

Add a 'global' option for API keys

replaces {
SomeSystem: Key
SomeSystem2: Key2
}

with {
global: key
}

tldr; replaces the need to spam API system keys with a single key

Types do not exist

I'll probably be able to make these but it will take a while

Issue: TypeScript hates the module due to no typings

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.