Skip to content

Commit a4fa3b7

Browse files
committed
type function in Lua
1 parent 42a5a16 commit a4fa3b7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

garrysmod/lua/includes/util.lua

+18
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,24 @@ function Material( name, words )
3030

3131
end
3232

33+
--[[---------------------------------------------------------
34+
type
35+
-----------------------------------------------------------]]
36+
function type( v )
37+
38+
local v_type = lua_type( v )
39+
if ( v_type != "userdata" ) then return v_type end
40+
41+
local metatable = getmetatable( v )
42+
if ( !metatable ) then return "UserData" end
43+
44+
local metaName = metatable.MetaName
45+
if ( lua_type( metaName ) != "string" ) then return "UserData" end
46+
47+
return metaName
48+
49+
end
50+
3351
--[[---------------------------------------------------------
3452
IsTableOfEntitiesValid
3553
-----------------------------------------------------------]]

0 commit comments

Comments
 (0)