LazyShpee

Implementation of custom types

Mar 8th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.43 KB | None | 0 0
  1. -- Will return metatable.__typename if present instead of always "table"
  2.  
  3. __lazy = __lazy or {}
  4. if not __lazy.type then
  5.     __lazy.type = type
  6.     function type(var)
  7.         local _type = __lazy.type(var);
  8.         if(_type ~= "table" and _type ~= "userdata") then
  9.             return _type;
  10.         end
  11.         local _meta = getmetatable(var);
  12.         if(_meta ~= nil and _meta.__typename ~= nil) then
  13.             return _meta.__typename;
  14.         else
  15.             return _type
  16.         end
  17.     end
  18. end
Advertisement
Add Comment
Please, Sign In to add comment