-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcess.lua
More file actions
36 lines (32 loc) · 985 Bytes
/
Process.lua
File metadata and controls
36 lines (32 loc) · 985 Bytes
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
local process = {};
local environmentsVar = "undefined";
if (script.Parent:FindFirstChild(".env")) then environmentsVar = require(script.Parent[".env"]); end;
process.memoryUsage = function()
return gcinfo("count");
end;
process.env = environmentsVar;
process.exit = function(code)
--[[
Don't use this if you dont have experience with exit on JavaScript!
process.exit(0) will destroy all current script (not including built-in script) and kick all players.
]]
if (typeof(code) ~= "number" and code ~= nil) then
warn("exit code should be number!");
return;
else
warn("process exited with: SIGTERM");
local Code = code or "unspecified code";
for i,v in pairs(game:GetDescendants()) do
if v:IsA("Script") and v ~= script then
local sucess, result
sucess, result = pcall(function()
v:Destroy();
end)
elseif v:IsA("Player") then
v:Kick("Process exited with code "..Code);
end;
end;
return nil;
end;
end;
return process;