-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyo.lua
More file actions
45 lines (39 loc) · 1.5 KB
/
Copy pathyo.lua
File metadata and controls
45 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
_G.Setup = _G.Setup or {}
local RealtimeU = _G.Setup
RealtimeU.request = syn and syn.request or http and http.request or http_request or fluxus and fluxus.request or getgenv().request or request
function RealtimeU:SaveFromJSON(JSONString, path, UID)
if not _G.Setup == {} then
local Response = RealtimeU.request({
Url = _G.Setup["Link"].."/"..path..".json",
Method = UID and "POST" or "PUT",
Body = JSONString
})
return game:GetService("HttpService"):JSONDecode(Response)
end
end
function RealtimeU:SaveFromTable(table, path, UID)
if not _G.Setup == {} then
local JSON = game:GetService("HttpService"):JSONEncode(table)
return RealtimeU:SaveFromJSON(JSON, path, UID)
end
end
function RealtimeU:SaveFromString(string, path, UID)
if not _G.Setup == {} then
local Response = RealtimeU.request({
Url = _G.Setup["Link"].."/"..path..".json",
Method = UID and "POST" or "PUT",
Body = string
})
return game:GetService("HttpService"):JSONDecode(Response)
end
end
function RealtimeU:GetFromPath(path, shallow)
if not _G.Setup == {} then
local Response = RealtimeU.request({
Url = shallow and _G.Setup["Link"].."/"..path..".json?shallow=true" or _G.Setup["Link"].."/"..path..".json",
Method = "GET"
})
return game:GetService("HttpService"):JSONDecode(Response)
end
end
return RealtimeU