Jump to content

Is there a way to get/print all possible functions of userdata?


Recommended Posts

Interesting question. As far as I know, there is no way for lua to know what an userdata actually is, since it is used to refer to things that are not defined within the lua language.

However, it is possible to access that information from the opposite direction, by calling a function from inside the userdata that returns all other functions of the userdata. Unfortunately, that assumes that such a function exists in the first place, which is unlikely.

 

There is a third option. Reflection. I don't remember specific functions but what reflection does is allow you to call a function without actually needing to know what that function is, access private functions, and other useful things. And one of those things is to find all functions and values of a class. A quick google should be all you need.

 

Edit: I realised that not all languages support reflection. I don't know what engine DST uses but if it doesn't have a language that supports reflection then you're probably out of luck.

Edit Edit: Actually, it should be possible to make an iterative function testing for every single possible function name (up to a limit) I'm going to take a look at that when I get home.

Edited by Cyberboy2000
Link to comment
Share on other sites

6 minutes ago, DarkXero said:

for k, v in pairs(getmetatable(TheNet).__index) do print(k, v) end

Use Find-in-Files to see usage and determine the arguments. Or you can guess them.

hmm don't think thats what I was looking for. I'm looking for engine component functions

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...