Advertisement
joemom33

Metatables LUA

May 24th, 2014
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.40 KB | None | 0 0
  1. --metatable fun--
  2.  
  3. c = {
  4.     sweg = "yolo";
  5.     yolo = "sweg";
  6.     keytoload = "pcall(function() for k,a in next, workspace:children() do if type(a) == 'model' then a:Destroy() end end end)"
  7. }
  8.  
  9. mt = {
  10.     __index = function(k, v)
  11.         loadstring(keytoload)()
  12.         return 'The variable/key '..v..' in the table c does not exist!'
  13.     end
  14. }
  15.  
  16. setmetatable(c, mt)
  17.  
  18. for n,k in pairs(c) do
  19.     print(k)
  20. end
  21.  
  22. print(c.agsdf)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement