As Code_gs explained in an edit note, Garry's Mod added more possible types than just those defined in Lua 5.1. I still think all possible return values should be listed, since this function is only useful when you know what return value you're expecting. As far as I know, there are still only a finite, set-in-virtual-stone set of types (defined in C++ somewhere).
Here are the values I know for sure:
Default to Lua 5.1:
- "no value", returned when there's no argument: type() (is this really default? the docs don't mention it)
Exclusive to gmod, in no particular order:
- Probably many others
Probably someone with access to the source code should grab the full list from that, rather than me filling out by hand with trial and error.
--NeatNit 12:39, 20 July 2018 (UTC)
- A full list of types is already available on TYPE_ Enums. I don't think all type strings should be listed as to not introduce another element that needs to be updated whenever a new type is updated. Also, GMod has a few differences from stock Lua with types, particularly, "userdata" is changed to "UserData" and type() with no args returns "no value" (sends an error in vanilla Lua).
- Code gs 14:58, 20 July 2018 (UTC)
- Regardless of that, I'll repeat my main point: this function is useless without knowing its return values for comparison. Even a partial list in the article (with a note) is better than none.
- I kinda hate how garry made Lua not behave like Lua in some regards. This is a perfect example - type is supposed to return "userdata" for all userdata types, but he just HAD to change it. But I guess that's a rant for another day...
- --NeatNit 23:51, 20 July 2018 (UTC)
- It's not much different than Lua 5.3's __type metamethod really. It retrieves the type name from the type's metatable's MetaName key. That's why Entity variants like players, weapons, and NPCs have their own type name, as opposed to TypeID which uses the internal lua type ID. It is a bit of a shitty hack for Lua 5.1. But anyway, these shouldn't be used for type checking so I don't think they should be documented.
- Code gs 03:32, 21 July 2018 (UTC)