I’m attempting to make a ModuleScript that returns all properties of the given ClassName. It works like so:
The script iterates through ALL classes, checks if the current class is the same as the given ClassName, and if yes, iterates through the Members (this is a table which contains methods, properties, etc), checks if the MemberType is “Property” (check if it is a property), and then adds the property to a table that will be returned by the ModuleScript. Quickly after, it’ll get the Superclass of the Superclass repeatedly until it finds the ‘Instance’ Superclass, while also adding the Superclass’ properties (the normal class will inherit from the Superclass, thus the definition of a Superclass).
And then, comes the problem. The same script has a filter for tags of each property (if a tag filter is given). These tags are strings such as “ReadOnly”, “Hidden”, etc. This filter works by iterating through the said Properties table and removing the property if it has a filtered tag. Code:
local MainModule = {}
function MainModule.GetAllProperties(Class, TagFilter)
assert((Class and typeof(Class) == 'string'), "invalid argument #1 to 'GetAllProperties' (string expected, got ".. typeof(Class) .. ")")
local Properties do
-- ClassProperties is a Dictionary of sorted arrays of Properties of Classes
-- Pulls from setup.roblox.com
-- Ignores deprecated and RobloxPluginSecurity Properties
-- Make sure HttpService is Enabled (Roblox Studio -> Home Tab -> Game Settings -> Security -> Allow HTTP requests = "On")
-- Also make sure that the website used it up to date.
Properties = {}
local HttpService = game:GetService("HttpService")
local function GetLatestVersion()
local Ver = HttpService:GetAsync("http://setup.rprxy.xyz/versionQTStudio")
local API = HttpService:JSONDecode(HttpService:GetAsync("https://setup.rprxy.xyz/" .. Ver .. "-API-Dump.json"))
return API
end
local Classes = GetLatestVersion().Classes
local function FindProperty(_Class, Property) -- Not being used.
for Index = 1, #_Class.Members do
local Value = _Class.Members[Index]
if Value.MemberType == 'Property' then
if Value.Name == Property then
return Value
end
end
end
end
for Index = 1, #Classes do -- Get the class
local _Class = Classes[Index]
local MemoryCategory = _Class.MemoryCategory
if MemoryCategory and MemoryCategory == 'Instances' then
if _Class.Name and typeof(_Class.Name) == 'string' and _Class.Name == Class then
for i = 1, #_Class.Members do
local Value = _Class.Members[i]
if Value.MemberType == 'Property' then
table.insert(Properties, Value)
end
end
Class = _Class
end
end
end
local CurrentSuperclass = Class
local function GetSuperclass(_Class)
for Index = 1, #Classes do
local class = Classes[Index]
local MemoryCategory = class.MemoryCategory
if MemoryCategory and MemoryCategory == 'Instances' then
if _Class.Superclass == class.Name then
return class
end
end
end
end
while CurrentSuperclass.Name ~= 'Instance' do
CurrentSuperclass = GetSuperclass(CurrentSuperclass)
local Members = CurrentSuperclass.Members
for i = 1, #Members do
local Value = Members[i]
if Value.MemberType == 'Property' then
table.insert(Properties, Value)
end
end
end
if TagFilter then -- This is the part of main interest
assert(typeof(TagFilter) == 'table', "invalid argument #2 to 'GetAllProperties' (table expected, got ".. typeof(TagFilter).. ')')
assert(#TagFilter > 0, 'Tag filter must have at least one value!')
for Index = 1, #Properties do
local Property = Properties[Index]
print(Properties)
if Property and Property.Tags then
for _, Tag in ipairs(Property.Tags) do
for i = 1, #TagFilter do
local FilteredTag = TagFilter[i]
-- print(Property.Name. Tag == FilteredTag)
if Tag == FilteredTag then
table.remove(Properties, Index)
end
end
end
end
end
end
print(Properties)
for Index = 1, #Properties do
local Property = Properties[Index]
if Property then
local Security = Property.Security
if Security.Read ~= 'None' or Security.Write ~= 'None' then
table.remove(Properties, Index)
end
end
end
--[[
for Index = 1, #Classes do -- Get the Superclass
local _Class = Classes[Index]
local MemoryCategory = _Class.MemoryCategory
if MemoryCategory and MemoryCategory == 'Instances' then
if _Class.Name == Class.Superclass then
local Members = _Class.Members
for i = 1, #Members do
local Value = Members[i]
if Value.MemberType == 'Property' then
table.insert(Properties, Value)
end
end
end
end
end
]]
end
return Properties
end
return MainModule
In the code of the tag filter, it checks if the Property has a tag, and then proceeds to check if the tag is filtered. The issue here is that despite the Property having tags, it DOES NOT meet the if statement requirement, or at least for one of the Properties. In my case, I am checking the properties of a ScreenGui, and “AbsoluteRotation” does not pass this if statement, despite having Tags.
Meanwhile, I’d also like tips to speed up all these processes, because there is quite a bunch of loops here.