Skip to content

Instantly share code, notes, and snippets.

@ALLAH-2
Created July 29, 2023 05:01
Show Gist options
  • Save ALLAH-2/d501a2b9302c1e08b021150bfd0dfe0f to your computer and use it in GitHub Desktop.
Save ALLAH-2/d501a2b9302c1e08b021150bfd0dfe0f to your computer and use it in GitHub Desktop.
okay
local API_DUMP_URL = "https://raw.githubusercontent.com/MaximumADHD/Roblox-Client-Tracker/roblox/API-Dump.txt";
local HttpService = game:GetService("HttpService");
local Reflection = {};
Reflection.__index = Reflection;
local function reflQuery(name)
return function(self, className)
local root = className;
local output = {};
while(root and self.output[root])do
-- Traverse through the reflection library
-- shallow copying over the nodes we traveled on.
local node = self.output[root];
root = node.extends;
for key, value in node[name] do
output[key] = value;
end
end
return output;
end
end
function Reflection:interpretArgs(word)
-- Interprets gsub stuff
local arguments = {};
while(true)do
local argType = word();
local argName = word();
if(not argName)then
break;
end
arguments[argName] = argType;
end
return arguments;
end
function Reflection:init(url, omit)
local raw = HttpService:GetAsync(url);
local output = {};
local offset;
local root;
local leaf;
-- Create whitelist
local whitelist = {};
for field in ([[
Class
Property
Function
Event
]]):gmatch("%w+") do
whitelist[field] = true;
end
-- Split file up
for _, line in raw:split('\n')do
local word = line:gmatch("[%w.:]+");
local field = word();
if(not whitelist[field])then
-- We only have functionality for
-- a set few entries.
continue;
elseif(field == "Class")then
-- CLASS NAME
root = word();
offset = #root+2;
word();
local extends = word();
leaf = {
methods = {};
events = {};
properties = {};
extends = extends;
};
output[root] = leaf;
elseif(field == "Property")then
-- PROPERTY FIELDTYPE class.NAME
local fieldType = word();
local name = word():sub(offset);
leaf.properties[name] = fieldType;
elseif(field == "Function")then
-- FUNCTION FIELDTYPE class:NAME(...)
local fieldType = word();
local name = word():sub(offset);
local arguments = self:interpretArgs(word);
arguments._returns = fieldType;
leaf.methods[name] = arguments;
elseif(field == "Event")then
-- EVENT class.NAME(...)
local name = word():sub(offset);
leaf.events[name] = self:interpretArgs(word);
end
end
self.output = output;
return self;
end
-- These methods should only be used sparingly(It's fast but should be cached).
-- This should really be referred to once.
Reflection.reflMethod = reflQuery("methods");
Reflection.reflEvent = reflQuery("events");
Reflection.reflProp = reflQuery("properties");
return Reflection:init(API_DUMP_URL);
@ALLAH-2
Copy link
Author

ALLAH-2 commented Jul 29, 2023

for u nerds: ya i didnt do all the data types but this is the majority of em

print(Reflection:reflEvent("Part"))
print(Reflection:reflMethod("Part"))
print(Reflection:reflProp("Part"))

@Nobonet
Copy link

Nobonet commented Jul 29, 2023

Ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment