Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. aTable = {}
  2.  
  3. for x=1,10,1 do
  4.   aTable[x] = x
  5. end
  6.  
  7. -- Metatable em Lua
  8. mt = {
  9.   __add = function(table1, table2)
  10.     sumTable = {}
  11.  
  12.     for y=1,#table1,1 do
  13.       if (table1[y] ~= nil) and (table2[y] ~= nil) then
  14.         sumTable[y] = table1[y] + table2[y]
  15.       else
  16.         sumTable[y] = 0
  17.       end
  18.     end
  19.  
  20.     print("FUNCIONA!!")
  21.     return sumTable
  22.   end,
  23.  
  24.   __eq = function(table1, table2)
  25.     print("FUNCIONA!!")
  26.     return table1.value == table2.value
  27.   end,
  28.  
  29.   __lt = function(table1, table2)
  30.     return table1.value < table2.value
  31.   end,
  32.  
  33.   __le = function(table1, table2)
  34.     return table1.value <= table2.value
  35.   end,
  36. }
  37.  
  38. setmetatable(aTable, mt)
  39.  
  40. --print(aTable == aTable)
  41.  
  42. addTable = {}
  43. if aTable == aTable then
  44.   local bool = (aTable == aTable)
  45.   addTable = aTable + aTable --and true or false
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement