Team Spartan Cookies & Milk Forums
type() for metatables - Printable Version

+- Team Spartan Cookies & Milk Forums (https://teamscm.co.uk)
+-- Forum: Garry's Mod (https://teamscm.co.uk/forum-4.html)
+--- Forum: Starfall (https://teamscm.co.uk/forum-7.html)
+--- Thread: type() for metatables (/thread-3571.html)



type() for metatables - The17thDoctor - 06-01-2021

I was wondering if there was a way to define what type() would print for meta objects (e.g, if we take back the example of the Colour in the SF tutorial, it'd print back "Colour" )


RE: type() for metatables - Person8880 - 07-01-2021

The type() function isn't really the right place for user-defined type checking. I'd suggest either checking the metatable, or if you are protecting the metatable, use the __metatable value which getmetatable returns to hold your type name.