Rbxcloud-luvit - ROC Wrapper for Luvit

Since I’ve seen Open Cloud wrappers for Python and NodeJS (a few of them actually…), I thought it would be a cool idea to join the party and create a wrapper for Luvit too.

Why use Luvit over other servers?

Luvit is made with Lua in mind, meaning everything you write on it, you use Lua.
This could mean very few things, but just as many things for others, but to make it short;

Alright, but what’s so special about this wrapper over others?

Well, the quick and easy answer is… nothing. There’s nothing new or special about this.

With that being said, I’ve attempted my best to try and replicate the Roblox service calls, meaning you can use the wrapper like this;

wrapper(token, universeId):GetDataStore("DatastoreName"):SetAsync("key","value");

or this;

wrapper(token, universeId):PublishMessage("GlobalAnnouncement","Hello world!!!")

Seems cool enough, how do we use this?

Download Luvit from here and follow the instructions.

Go to the rbxcloud-luvit github, and select which option you want. (Clicking on this link will take you to the full version)

Afterwards, copy the lua code, and open your project’s ‘deps’ folder. Create a new file within it, and name it ‘rbxcloud’.

After you’ve done that, you should be able to call the wrapper at any time using this;

local wrapper = require('rbxcloud');
local Universe = wrapper(token, universeId);

local datastore = Universe:GetDataStore("DatastoreName")

When done, you should be able to call luvit [filename].lua and see it come to life!

…you get the point hopefully.

I’ve got an issue! How do I report it?

You can report any issues you get from using the wrapper here. (You will need to open a Github account if you don’t already have one.)

Alternatively, you can contact me on Discord if you feel like Github is a waste of time.

Is there an API reference anywhere?

Sure, it’s here if you haven’t used any of the Roblox services before.

API Cheat Sheet
local Wrapper = require("rbxcloud");
local Connection = Wrapper(token:string, universeId:string|number);

-- Publishing a new version; https://create.roblox.com/docs/open-cloud/place-publishing-api
local NewVersion:{versionNumber:number} = Connection:PushNewVersion(placeId:string|number,versionXML:xml,pushmethod:string("Published"|"Saved"));

-- Publishing a MessagingService Message; https://create.roblox.com/docs/open-cloud/messaging-service-api
local Success:boolean = Connection:PublishMessage(topic:string,message:string);

-- Datastore API (the EXCITING part!); https://create.roblox.com/docs/open-cloud/data-store-api
-- List all Datastores
local DatastoreList:table = Connection.ListDataStoresAsync(prefix:string,limit:string|number,cursor:string|number);

-- NOTICE: Connect to a datastore BEFORE attempting to do datastore-specific functions!
local MyDatastore = Connection:GetDataStore(datastoreName)

-- Get all Keys
local Keys:table = MyDatastore:ListKeysAsync(scope,AllScopes,prefix,limit,cursor)

-- Get a value from a key
local Value:any? = MyDatastore:GetAsync(entryKey,scope)

-- Set a value to a key
local Success:boolean = MyDatastore:SetAsync(entryKey,entryValue,scope)

-- Increment value
local NewValue:number? = MyDatastore:IncrementAsync(entryKey,IncrementBy,scope)

-- Remove a key from the datastore
local Success:boolean = MyDatastore:RemoveAsync(entryKey,scope)

-- List versions (honestly i doubt anyone will actually use it but it's there)
local Versions:table = MyDatastore:ListVersionsAsync(entryKey,scope,limit,cursor,sortOrder,startTime,endTime)

-- Get specific version for a key
local Version:table = MyDatastore:GetVersionAsync(entryKey,scope,versionId)
7 Likes

I tried using it and ended up having to change a portion of the code, the headers were formatted incorrectly for the coro-http module to use.

This code

	local headers = {
    	['x-api-key'] = token;
		['Content-Type'] = 'application/json';
    }

Had to be replaced with this code in order to work properly and send the api key

	local headers = {
        {'x-api-key', token};
        {'Content-Type', 'application/json'};
	}

This is despite having the correct version of the coro-http module according to your modules dependencies.

Otherwise, this is a useful module that saved a lot of headache figuring out how robloxes open cloud API works.

2 Likes

Thanks for letting me know, I’ll edit the github page as soon as I’ll get the chance to.

EDIT; I have fixed the headers as promised.

1 Like

Finally, Roblox Cloud in Luvit.

Updated to 1.1.0, which adds support for OrderedDatastores.

Luvit is still very much underappreciated, so you should definitely check it out if you don’t already know about it.