lua : rework the way types representing an object with an int id work

this fix bug #9698 where equality wouldn't be true in all case