Meta Tables?

I was wondering, since I’m going to soon be adding to my gamemode real estate, exactly what are Meta Tables and what are they used for? Like what all can they do, etc.

They are pretty much lua’s form of operator overloading.
Here’s a list of meta functions you can use



__add(a,b)			(a+b)
__sub(a,b) 			(a-b)
__mul(a,b)			(a*b)
__div(a,b)			(a/b)
__index(a,b)		(a**)
__newindex(a,b,c)	(a**=c)
__len(a)			(#a)
__tostring(a)		(tostring(a))
__pow(a,b)			(a^b)
__mod(a,b)			(a%b)
__concat(a,b)                    (a..b) --thanks overv


[editline]25th October 2010[/editline]

An example
[lua]
local meta = {}
function meta.__add(a,b)

return "banana"..b

end

local t = {}
setmetatable(t,meta)

print(t+“orange”)
[/lua]
Outputs



bananaorange


You missed _concat (a…b).

There are methods for bit shifts too, but I forgot the exact names.