Advertisement
CloneTrooper1019

[Roblox] Script Environment Metatable Override

Feb 22nd, 2015
684
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. function OverrideEnv()
  2.     local funcDump =
  3.     {
  4.         -- Basics
  5.             "assert","collectgarbage","dofile","error","_G","gcinfo","getfenv","getmetatable","ipairs","load",
  6.             "loadfile","loadstring","newproxy","next","os","pairs","pcall","print","rawequal","rawget","rawset",
  7.             "select","setfenv","setmetatable","tonumber","tostring","type","unpack","_VERSION",
  8.            
  9.         -- Manipulation and Roblox Functions
  10.             "coroutine","string","table","math","Delay","ElapsedTime","LoadLibrary","printidentity",
  11.             "require","Spawn","tick","time","version","wait","warn","ypcall","game","workspace",
  12.        
  13.         -- Data Types
  14.             "Axes","BrickColor","CFrame","Color3","Faces","Instance","Ray","Region3","Region3int16",
  15.             "UDim","UDim2","Vector2","Vector3","Vector3int16","Vector2int16","CellId"
  16.     }
  17.     local env = {}
  18.     local currentEnv = getfenv(2)
  19.     for _,v in pairs(funcDump) do
  20.         env[v] = currentEnv[v]
  21.     end
  22.     for k,v in pairs(currentEnv) do
  23.         env[k] = v
  24.     end
  25.     local meta =
  26.     {
  27.         __newindex = function(self,index,value)
  28.             print("Variable: '"..index.."' is getting set to: "..value)
  29.             if rawget(self,index) ~= value then
  30.                 rawset(self,index,value)
  31.             end
  32.         end
  33.     }
  34.     setmetatable(env,meta)
  35.     setfenv(2,env)
  36. end
  37.  
  38. return OverrideEnv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement