overwriting meta functions

Issue:
i am unable to overwrite functions defined in the entity metatable in a specific manner.

Setup:
[lua]
local meta = FindMetaTable(“Entity”)
function meta:c()
print(“testing”)
self.c = function() print(“testing2”) return “cats” end
return “cheese”
end
[/lua]

Testing:
[lua]
local testEnt = player.GetAll()[1]:GetEyeTrace().Entity
print( tostring( testEnt:c() ) )

timer.Simple(2,function()
print( tostring( testEnt:c() ) )
end )
[/lua]

Output:
[lua]
testing
cheese

testing
cheese
[/lua]

Suggestions/ideas?

That’s because “self.c” doesn’t overwrite the function in the metatable, it adds “c” to the entity’s instance table. By default, the entity’s __index will search the metatable before its instance.