forked from probablYnicKxD/ProjectLunar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lunar API.lua
110 lines (87 loc) · 2.25 KB
/
Lunar API.lua
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
local lunar = {}
function lunar.chat(msg)
game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest:FireServer(msg, "All")
end
function lunar.getexecutor(includelunar)
if includelunar and includelunar == true then
local exec = identifyexecutor() or "Unknown"
return "LunarExecutor // " .. exec
else
return identifyexecutor() or "Unknown"
end
end
function lunar.protectui(ui)
if syn and syn.protect_gui then
syn.protect_gui(ui)
return true
elseif protect_gui then
protect_gui(ui)
return true
else
error("LunarExecutor // The executor that LunarExecutor is being used on does not support protect_gui!")
return false
end
end
function lunar.request(requestinfo)
local req = nil
if syn and syn.request then
req = syn.request
elseif http and http.request then
req = http.request
elseif http_request then
req = http_request
else
error("LunarExecutor // The executor that LunarExecutor is being used on does not support http requests!")
return nil
end
return req(requestinfo)
end
function lunar.kick(msg)
if msg then
game.Players.LocalPlayer:Kick(msg)
else
game.Players.LocalPlayer:Kick()
end
end
function lunar.load(path)
local file = isfile(path)
if file then
return readfile(path)
else
error("Invalid file - File not found! Make sure the file is in the executor's workspace folder.")
return nil
end
end
local chatEvents = game:GetService("ReplicatedStorage"):WaitForChild("DefaultChatSystemChatEvents")
local messageDoneFiltering = chatEvents:WaitForChild("OnMessageDoneFiltering")
lunar.onplayerchatted = messageDoneFiltering.OnClientEvent
local signals = {}
function lunar.createsignal()
local newsignal = {
Connections = {},
}
function newsignal:Fire(...)
local args = {...}
for i, con in pairs(newsignal.Connections) do
local success, err = pcall(function()
con.ConnectedFunction(table.unpack(args))
end)
if not success and err then
error(err)
end
end
end
function newsignal:Connect(con)
local newcon = {
ConnectedFunction = con,
}
function newcon:Disconnect()
table_remove(newsignal.Connections, newcon)
end
table.insert(newsignal.Connections, newcon)
return newcon
end
table.insert(signals, newsignal)
return newsignal
end
return lunar