Garry's Mod Wiki

Revision Difference

Global.type#511341

<function name="type" parent="Global" type="libraryfunc">⤶ <description>Returns a string representing the name of the type of the passed object.</description>⤶ <realm>Shared and Menu</realm>⤶ <args>⤶ <arg name="var" type="any">The object to get the type of.</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="string">The name of the object's type.</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Print the name of a few types.</description>⤶ <code>⤶ print( type(2) )⤶ print( type("hai") )⤶ print( type({}) )⤶ </code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>⤶ number⤶ string⤶ table⤶ </output>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>Returns "no value" if called with 0 arguments/parameters.</description>⤶ <code>print( type() )</code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>no value</output>⤶ ⤶ </example>⤶ ⤶ ⤶ <example>⤶ <description>A list of code showing how you can use the type function in replacement with any of the "is" functions. (example being <page>Global.istable</page>, <page>Global.isentity</page>, etc.)</description>⤶ <code>⤶ print(type(LocalPlayer()))⤶ print(type(Vector()))⤶ print(type(Angle()))⤶ print(type(Entity(num))) -- -&amp;gt; num is the EntIndex for the entity⤶ print(type(vgui.Create("DFrame")))⤶ </code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>⤶ Player⤶ Vector⤶ Angle⤶ Entity⤶ Panel⤶ </output>⤶ ⤶ </example>