-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
285 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.