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 = {}
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.
2 comments
Do you mean like for a GUI, could it retrieve its properties, and w/ a BasePart (Part/ Brick), it retrieves its properties, w/o typing code for that beforehand? Or not? Could you please expand on what you mean? :)
Any Instance