Skip to content

Commit

Permalink
Format luau
Browse files Browse the repository at this point in the history
  • Loading branch information
Coyenn committed Dec 11, 2022
1 parent ba39e76 commit 8b6f24e
Show file tree
Hide file tree
Showing 10 changed files with 285 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ jobs:
- run: pnpm install && pnpm build:client
- uses: actions/upload-artifact@v2
with:
name: Roblox-DRPC.rbxm
name: Roblox-DRPC-Plugin
path: dist/client/roblox-drpc.rbxm
3 changes: 2 additions & 1 deletion aftman.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

# To add a new tool, add an entry to this table.
[tools]
rojo = "rojo-rbx/[email protected]"
rojo = "rojo-rbx/[email protected]"
stylua = "johnnymorganz/[email protected]"
44 changes: 24 additions & 20 deletions src/client/index.server.luau
Original file line number Diff line number Diff line change
@@ -1,47 +1,51 @@
-- CREDITS TO RIGID STUDIOS FOR MAKING THIS OPEN SOURCED!! THIS ISNT MY ORIGINAL SCRIPT, JUST HEAVILY EDITED!

script.Parent.src.activity:SetAttribute("started",os.time())
local started=false
script.Parent.src.activity:SetAttribute("started", os.time())
local started = false

local function start()
local StudioPresence = script:FindFirstAncestor("StudioPresence");
local StudioPresence = script:FindFirstAncestor("StudioPresence")
local env = {
["plugin"] = plugin
["plugin"] = plugin,
}

for i,v in ipairs(StudioPresence:GetDescendants()) do
for i, v in ipairs(StudioPresence:GetDescendants()) do
if v:IsA("ModuleScript") then
local m = require(v)
setmetatable(m,{__index = env})
setmetatable(m, { __index = env })
end
end

local Data = require(StudioPresence.src.dataHandler);
local Client = require(StudioPresence.src.client.index);
local Data = require(StudioPresence.src.dataHandler)
local Client = require(StudioPresence.src.client.index)

local Http = require(StudioPresence.src.httpClient).new("http://localhost:4455/");
local ClientObj = Client.new(Http, false);
local Http = require(StudioPresence.src.httpClient).new("http://localhost:4455/")
local ClientObj = Client.new(Http, false)

Data:AttachChange("Enabled", function(isEnabled)
if isEnabled then ClientObj:Open() else ClientObj:Close() end;
if isEnabled then
ClientObj:Open()
else
ClientObj:Close()
end
end)

plugin.Unloading:Connect(function()
ClientObj.Enabled = false;
ClientObj.Terminated = true;
end);
ClientObj.Enabled = false
ClientObj.Terminated = true
end)

ClientObj:login(function(success)
if success then
started=true
started = true
else
wait(3)
start()
ClientObj.Enabled = false;
end;
end);
ClientObj.Enabled = false
end
end)
end

if started==false then
if started == false then
start()
end
end
76 changes: 42 additions & 34 deletions src/client/src/activity.luau
Original file line number Diff line number Diff line change
@@ -1,65 +1,73 @@
local activity = {};
local startTick = os.time();
local activity = {}
local startTick = os.time()

function activity.new()
-- Please don't remove this, I need jobs... :D
return setmetatable({ assets = {} }, { __index = activity });
end;
return setmetatable({ assets = {} }, { __index = activity })
end

function activity:clear()
self.buttons = nil;
self.timestamps = nil;
self.buttons = nil
self.timestamps = nil

return self;
end;
return self
end

function activity:addButton(buttonName, buttonValue)
if buttonName and buttonValue and buttonName ~= "" and buttonValue ~= "" then
if not self.buttons then self.buttons = {} end;
if not self.buttons then
self.buttons = {}
end

-- TODO?: Surplus buttons check.
self.buttons[#self.buttons + 1] = { label = buttonName, url = buttonValue };
end;
self.buttons[#self.buttons + 1] = { label = buttonName, url = buttonValue }
end

return self;
end;
return self
end

function activity:setDescription(detailsValue)
self.details = detailsValue;
self.details = detailsValue

return self;
end;
return self
end

function activity:setState(stateValue)
self.state = stateValue;
self.state = stateValue

return self;
end;
return self
end

function activity:setTimer()
if not self.timestamps then self.timestamps = {} end;
if not self.timestamps then
self.timestamps = {}
end
self.timestamps = {
start = script:GetAttribute("started");
};
start = script:GetAttribute("started"),
}

return self;
end;
return self
end

function activity:setImage(imageName,text)
if not self.assets then self.assets = {} end;
function activity:setImage(imageName, text)
if not self.assets then
self.assets = {}
end

self.assets.large_image = imageName
self.assets.large_text = text
return self;
end;
return self
end

function activity:setThumbnail(imageName,text)
if not self.assets then self.assets = {} end;
function activity:setThumbnail(imageName, text)
if not self.assets then
self.assets = {}
end

self.assets.small_image = imageName
self.assets.small_image_key = text;
self.assets.small_image_key = text

return self;
end;
return self
end

return activity;
return activity
76 changes: 38 additions & 38 deletions src/client/src/client/index.luau
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
local client = {};
local StudioPresence = script:FindFirstAncestor("StudioPresence");
local client = {}
local StudioPresence = script:FindFirstAncestor("StudioPresence")

local ActivityCreator = require(StudioPresence.src.generators.activityCreator);
local Data = require(StudioPresence.src.dataHandler);
local ActivityCreator = require(StudioPresence.src.generators.activityCreator)
local Data = require(StudioPresence.src.dataHandler)

function client.new(Http, _debug)
local self = setmetatable({ Http = Http, _debug = _debug }, { __index = client });
return self;
end;
local self = setmetatable({ Http = Http, _debug = _debug }, { __index = client })

return self
end

function client:Close()
self.Enabled = false;
self.Enabled = false
self.Http:Post({
updateType = "CLOSE";
});
end;
updateType = "CLOSE",
})
end

function client:SetActivity()
return self.Http:Post({
updateType = "SET_ACTIVITY";
activity = ActivityCreator:Get();
});
end;
updateType = "SET_ACTIVITY",
activity = ActivityCreator:Get(),
})
end

function client:Open()
self.Enabled = true;
return self:SetActivity();
end;
self.Enabled = true
return self:SetActivity()
end

-- Initiate with cb -> callback(success<bool>, response<string>);
function client:login(cb)
local enabled = Data:Get("Enabled");
local enabled = Data:Get("Enabled")

local success, reply;
local success, reply
if enabled or enabled == nil then
success, reply = self:Open();
success, reply = self:Open()
else
success = false;
end;
success = false
end

spawn(function()
while 1 do
wait(2.6); -- Accuracy un-necessary.
wait(2.6) -- Accuracy un-necessary.

if self.Enabled then
self:SetActivity();
end;
self:SetActivity()
end

if self.Terminated then
break;
end;
end;
end);
break
end
end
end)

if cb then
cb(success, reply);
end;
cb(success, reply)
end

self.plugin.Unloading:Connect(function()
self:Close();
end);
end;
self:Close()
end)
end

return client;
return client
50 changes: 26 additions & 24 deletions src/client/src/dataHandler.luau
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
local dataHandler = { data = {}, attachments = {} };
local dataHandler = { data = {}, attachments = {} }

function dataHandler:Set(key, data)
self.data[key] = data;
self.data[key] = data

if self.attachments[key] then
for _, func in pairs(self.attachments[key]) do
func(data);
end;
end;
func(data)
end
end

return data;
end;
return data
end

function dataHandler:Get(key)
local data = self.data[key];
local data = self.data[key]
if data == nil or data == "" then
data = self.plugin:GetSetting(key);

self.data[key] = data;
end;
data = self.plugin:GetSetting(key)

return data;
end;
self.data[key] = data
end

return data
end

function dataHandler:AttachChange(key, func)
if not self.attachments[key] then self.attachments[key] = {} end;

table.insert(self.attachments[key], func);
end;
if not self.attachments[key] then
self.attachments[key] = {}
end

table.insert(self.attachments[key], func)
end

function dataHandler:Save()
for key, value in pairs(self.data) do
self.plugin:SetSetting(key, value);
end;
return dataHandler;
end;
self.plugin:SetSetting(key, value)
end

return dataHandler
end

return dataHandler;
return dataHandler
Loading

0 comments on commit 8b6f24e

Please sign in to comment.