This repository has been archived by the owner on Dec 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEnv.lua
78 lines (61 loc) · 2.6 KB
/
Env.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
--[[
<ModuleScript> Env
ENV HANDLER
This handy script allows you to reset script Envs and set them
Does make use of global variables so don't put stuff in there that you use once
CHECK DOCS UNDER THIS SCRIPT!!!!
Phoenix
]]
local CT = function(Table)
local NewTable = {}
for Index, Value in pairs(Table) do
NewTable[Index] = Value
end
return NewTable
end;
--// \/ OVERRIDE SCRIPT FUNCTION GLOBALS DOWN HERE \/
local print = function(...) for Index, Value in pairs({...}) do print("[".. getfenv(2).script.Name .."]: ".. tostring(Value)) end end
local warn = function(...) for Index, Value in pairs({...}) do warn("[".. getfenv(2).script.Name .."]: ".. tostring(Value)) end end
-- local error = function(...) for Index, Value in pairs({...}) do ADDREPORTHERE error(Value) end end
local Env = {
_G = _G, game = game, getfenv = getfenv, setfenv = setfenv,
getmetatable = getmetatable, setmetatable = setmetatable, coroutine = coroutine,
rawequal = rawequal, typeof = typeof, print = print, math = math, warn = warn,
error = error, pcall = pcall, xpcall = xpcall, rawset = rawset, rawget = rawget,
ipairs = ipairs, pairs = pairs, next = next, Rect = Rect, Axes = Axes, os = os,
tick = tick, Faces = Faces, unpack = unpack, string = string, Color3 = Color3,
newproxy = newproxy, tostring = tostring, tonumber = tonumber, Instance = Instance,
TweenInfo = TweenInfo, BrickColor = BrickColor, NumberRange = NumberRange,
ColorSequence = ColorSequence, NumberSequence = NumberSequence,
ColorSequenceKeypoint = ColorSequenceKeypoint, NumberSequenceKeypoint = NumberSequenceKeypoint,
PhysicalProperties = PhysicalProperties, Region3int16 = Region3int16, Vector3int16 = Vector3int16,
elapsedTime = elapsedTime, require = require, table = table, type = type, wait = wait,
Enum = Enum, UDim = UDim, UDim2 = UDim2, Vector2 = Vector2, Vector3 = Vector3,
Region3 = Region3, CFrame = CFrame, Ray = Ray, Random = Random, spawn = spawn
};
--// Return
return function(Table)
local OrgEnv = getfenv(2)
local Reset = CT(Table)
local Table = Table
setfenv(2, setmetatable({},{
__index = function(Self, Index)
if Table[Index] ~= nil then
return Table[Index]
elseif Index == "RESETSCRIPTENV" then
for Index, Value in pairs(Reset) do
Table[Index] = Value
end
return function() return "RESET" end
elseif Env[Index] ~= nil then
return Env[Index]
else
return OrgEnv[Index]
end
end;
__newindex = function(Self, Index, Key)
Table[Index] = Key
end;
__metatable = {}; --// Just ensures you can't run Build twice
}))
end;