I am not requesting a script, I just want to know how I would go about doing this.
Is it possible to get the names of every property in a instance as a table?
For example if a were to:
for name in pairs(Properties) do print(name) end
where Properties would be a table of property names.
If anyone knows a way to get this information it would be a great help.
If you either copy/paste into a script or perhaps use HTTPService to get the content of API:Class reference/Dump, you can parse the results and make the table of properties automatically.
If you use the copy/paste method, you'll want to put it into a script in this fashion:
input = [=[PASTE IT HERE]=]
The [=[ starts a string block that will not end until it gets to a ]=]. The reason to use that instead of "" is to allow for newlines.
I wrote the following parsing algorithm a while ago:
PropExists = {} function copy(dict) local new = {} for k,v in pairs(dict) do new[k] = v end return new end local waitForNextClass = false deprecated = {} --deprecated classes for line in input:gmatch("[^\n]+") do if string.find(line, "%[deprecated%]") == nil then if line:sub(1, 1) ~= string.char(9) then waitForNextClass = false if string.find(line, ":") ~= nil then _, _, className, superClass = string.find(line, "Class ([%w_]+)%s:%s([%w_]+)") if deprecated[superClass] then deprecated[className] = true waitForNextClass = true else curClass = copy(PropExists[superClass]) end else _, _, className = string.find(line, "Class ([%w_]+)") curClass = {} end PropExists[className] = curClass elseif not waitForNextClass then _, _, name = string.find(line, "%s+[%w_]+%s+[%w_]+%s*[%w_]*.([%w_]+)") if name == nil then print(line) end curClass[name] = true end elseif line:sub(1, 1) ~= string.char(9) then waitForNextClass = true _, _, className = string.find(line, "Class ([%w_]+)") deprecated[className] = true end end return PropExists
Note that it expects its input
variable to start with "Class Instance [notbrowsable]" (input
must exist before line 1 above). It ignores deprecated entries. It is meant to be in a ModuleScript; it returns a dictionary which you might access like this:
PropExists[className][PropertyFieldEventOrFunctionName] == true or false
ex PropExists["Part"]["Position"] will be true.
Unfortunatly, you can't get all properties without having a table that contains every property of that instance. (Wich you'd have to make yourself)
If you'd want to print all properties of a instance, you'd first have to store all the properties that instance has, inside a table, then iterate through that table (using a for
loop) and change the properties like that.