Advertisement
Derek1017

Safe Enviroment

Mar 1st, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. --[[
  2.  
  3. Welcome to smartVM by 12packkid, this is a representation of
  4. everything inside the environment, with cool little new things.
  5. See if you can find the joke inside the math table! :)
  6.  
  7. To change anything in the environment, just go into the 'env' table
  8. and find what you want to change, change it as you wish! Be careful though!
  9. To add anything then you need to go into the 'env' table, and either add it
  10. to a library or add it as part of the global environment.
  11.  
  12. THIS IS NOT A SANDBOX!!
  13. I did not design this to be a sandbox, so don't be surprised if you run this
  14. and someone kicks you. Although you can change core functions, I did * not *
  15. intend for this to become a sandbox.
  16.  
  17. Thank you, also, to run a piece of code in the virtual machine, go to the
  18. bottom of the script and call the Wrap function with the correct arguments.
  19. This has custom error handling as well.
  20.  
  21. Thanks, Sam (12packkid).
  22. ]]
  23.  
  24. local CoreFuncs = {
  25. ["MoveTable"] = function(table1,table2)
  26. for i,v in pairs(table2) do
  27. if type(i) == "string" then
  28. table1[i] = v
  29. else
  30. table.insert(table1,v)
  31. end
  32. end
  33. end
  34. }
  35. local env = {
  36. table = {
  37. insert = table.insert;
  38. remove = table.remove;
  39. getn = table.getn;
  40. sort = table.sort;
  41. foreach = table.foreach;
  42. foreachi = table.foreachi;
  43. concat = table.concat;
  44. unpack = unpack;
  45. maxn = table.maxn;
  46. move = CoreFuncs.MoveTable;
  47. };
  48. string = {
  49. sub = string.sub;
  50. char = string.char;
  51. byte = string.byte;
  52. upper = string.upper;
  53. lower = string.lower;
  54. dump = string.dump; -- does not return actual dump
  55. match = string.match;
  56. len = string.len;
  57. gmatch = string.gmatch;
  58. gsub = string.gsub;
  59. format = string.format;
  60. find = string.find;
  61. reverse = string.reverse;
  62. rep = string.rep;
  63. convertNumber = tonumber;
  64. convertString = tostring;
  65. };
  66. math = {
  67. random = math.random;
  68. over9000 = 9001;
  69. pi = math.pi;
  70. max = math.max;
  71. min = math.min;
  72. huge = math.huge;
  73. sin = math.sin;
  74. tan = math.tan;
  75. cos = math.cos;
  76. acos = math.acos;
  77. atan = math.atan;
  78. asin = math.asin;
  79. tanh = math.tanh;
  80. abs = math.abs;
  81. sqrt = math.sqrt;
  82. cosh = math.cosh;
  83. randomseed = math.randomseed;
  84. pow = math.pow;
  85. exp = math.exp;
  86. fmod = math.fmod;
  87. frexp = math.frexp;
  88. floor = math.floor;
  89. ceil = math.ceil;
  90. log = math.log;
  91. log10 = math.log10;
  92. rad = math.rad;
  93. ldexp = math.ldexp;
  94. deg = math.deg;
  95. atan2 = math.atan2;
  96. };
  97. io = {};
  98. debug = {};
  99. os = {
  100. time = os.time;
  101. difftime = os.difftime;
  102. };
  103. print = print;
  104. assert = assert;
  105. error = error;
  106. loadstring = loadstring;
  107. setmetatable = setmetatable;
  108. getmetatable = getmetatable;
  109. newproxy = newproxy;
  110. dofile = dofile; -- cannot be used in rbx.lua
  111. load = load; -- cannot be used in rbx.lua - see dofile
  112. loadfile = loadfile; -- cannot be usd in rbx.lua - see load/dofile
  113. getfenv = getfenv;
  114. setfenv = setfenv;
  115. Game = game;
  116. game = game;
  117. workspace = workspace;
  118. Workspace = workspace;
  119. Instance = {
  120. new = Instance.new;
  121. Lock = Instance.Lock;
  122. Unlock = Instance.Unlock;
  123. };
  124. CFrame = {
  125. new = CFrame.new;
  126. fromEulerAnglesXYZ = CFrame.fromEulerAnglesXYZ;
  127. fromAxisAngle = CFrame.fromAxisAngle;
  128. Angles = CFrame.Angles;
  129. };
  130. Vector3 = {
  131. new = Vector3.new;
  132. FromAxis = Vector3.FromAxis;
  133. FromNormalId = Vector3.FromNormalId;
  134. };
  135. coroutine = {
  136. resume = coroutine.resume;
  137. create = coroutine.create;
  138. yield = coroutine.yield;
  139. status = coroutine.status;
  140. running = coroutine.running;
  141. wrap = coroutine.wrap;
  142. };
  143. UDim2 = {
  144. new = UDim2.new;
  145. };
  146. Vector2 = {
  147. new = Vector2.new;
  148. };
  149. Spawn = spawn;
  150. spawn = spawn;
  151. pcall = pcall;
  152. ypcall = ypcall;
  153. xpcall = xpcall;
  154. rawget = rawget;
  155. rawset = rawset;
  156. rawequal = rawequal;
  157. type = type;
  158. tonumber = tonumber;
  159. tostring = tostring;
  160. _VERSION = _VERSION;
  161. _VERSION2 = "12packkid's VM v0.25";
  162. unpack = unpack;
  163. select = select;
  164. next = next;
  165. pairs = pairs;
  166. ipairs = ipairs;
  167. _G = _G;
  168. gcinfo = gcinfo;
  169. collectgarbage = collectgarbage;
  170. wait = wait;
  171. Wait = wait;
  172. }
  173. function Wrap(c)
  174. for i,v in pairs(env) do
  175. getfenv(c)[i] = v;
  176. end
  177. local a,b = spawn(function()
  178. c()
  179. end)
  180. if not a then
  181. getfenv(c).print(b)
  182. end
  183. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement