Packages
ClassIndex

ClassIndex

A package that enables developers to get context about specific Roblox classes, this package uses a late-ish dump of the Roblox API to be able to query information such as the superclasses for a specific class, properties for specific classes and so fourth.

This package uses the lune (opens in a new tab) runtime to update the 'generated-api-dump'

Properties

Methods

Functions

GetApiDump

ClassIndex.GetApiDump() -> ApiDump

Returns the Roblox 'Api Dump' that the package is currently using.

	local ApiDump = ClassIndex.GetApiDump()
 
	print(ApiDump.Classes["Workspace"].Members)

GetAllClasses

ClassIndex.GetAllClasses() -> { string } (opens in a new tab)

Returns an array of all classes in the Roblox Engine

	local classNames = ClassIndex.GetAllClassNames()
 
	for _, className in classNames do
		print(className)
	end

IsClassRegistered

ClassIndex.IsClassRegistered( className string (opens in a new tab) ) -> boolean (opens in a new tab)

Returns wheather the Api Dump the package is using contains metadata on a class

	local isClassSupported = ClassIndex.IsClassRegistered("Workspace")
 
	if isClassSupported then
		local workspaceMembers = ClassIndex.GetClassMembers("Workspace")
 
		...
	end

GetClassMembers

ClassIndex.GetClassMembers( className string (opens in a new tab), security string? (opens in a new tab), includeNonScriptable boolean? (opens in a new tab) ) -> { string } (opens in a new tab)

Returns the 'Members' of a class, class members could be one of many things, ranging from;

  • Methods
  • Events
  • Properties
	local workspaceMembers = ClassIndex.GetClassMembers("Workspace")
 
	local workspaceMethods = {}
	local workspaceEvents = {}
	local workspaceProperties = {}
 
	for _, memberName in workspaceMembers do
		local indexType = typeof(workspaceMethods[memberName])
 
		if indexType == "function" then
			table.insert(workspaceMethods, memberName)
		elseif indexType == "RbxScriptSignal" then
			table.insert(workspaceEvents, memberName)
		else
			table.insert(workspaceProperties, memberName)
		end
	end

GetClassIcon

ClassIndex.GetClassIcon( className string (opens in a new tab) ) -> { Image: string, ImageRectOffset: Vector2, ImageRectSize: Vector2 }

Re-implements the :GetClassIcon call seen under 'StudioService', allowing developers outside of the Plugin space to get class icons.

https://create.roblox.com/docs/reference/engine/classes/StudioService#GetClassIcon (opens in a new tab)

Curse you Roblox! Why is this locked to just plugins?!

	local label = Instance.new("ImageLabel")
	
	for property, value in ClassIndex.GetClassIcon("Workspace") do
		label[property] = value
	end
 
	...

GetClassMemberType

ClassIndex.GetClassMemberType( className string (opens in a new tab), memberName string (opens in a new tab) ) -> string (opens in a new tab)

Returns the 'MemberType' of a class member.

	local gravityMemberType = ClassIndex.GetClassMemberType("Workspace", "Gravity")
 
	print(gravityMemberType) -- "Property"

GetClassMemberTags

ClassIndex.GetClassMemberTags( className string (opens in a new tab), memberName string (opens in a new tab) ) -> { Hidden: boolean?, NotReplicated: boolean?, ReadOnly: boolean?, Deprecated: boolean? }

Returns the tags that have been applied to a class member.

	local gravityMemberTags = ClassIndex.GetClassMemberTags("Workspace", "Gravity")
 
	if gravityMemberTags.Deprecated then
		print("Oh noo! Where did Gravity go?!")
	end

GetClassMemberSecurity

ClassIndex.GetClassMemberSecurity( className string (opens in a new tab), memberName string (opens in a new tab) ) -> { Read: string, Write: string }

Returns a table containg both a Read and Write key, the value sof these keys will define if the developer has access to write and read the member of that class.

	local memberSecurity = ClassIndex.GetClassMemberSecurity("Workspace", "Gravity")
 
	if memberSecurity.Read == "None" then
		local gravity = workspace.Gravity
	end

GetClassMemberThreadSafety

ClassIndex.GetClassMemberThreadSafety( className string (opens in a new tab), memberName string (opens in a new tab) ) -> string (opens in a new tab)

Returns a string defining if the developer can access/manipulate that member when using roblox's multi threading feature.

	local memberThreadSafe = ClassIndex.GetClassMemberThreadSafety("Workspace", "Gravity")
 
	if memberSecurity == "Safe" then
		task.desynchronize()
 
		workspace.Gravity *= 2
 
		task.synchronize()
	end

GetClassSuperclass

ClassIndex.GetClassSuperclass( className string (opens in a new tab) ) -> string (opens in a new tab)

Returns the superclass of a given class. For etcetera, the Workspace's superclass is 'WorldRoot'!

	local workspaceSuperclass = ClassIndex.GetClassSuperclass("Workspace")
 
	print(workspaceSuperclass) -- "WorldRoot"

GetClassSuperclasses

ClassIndex.GetClassSuperclasses( className string (opens in a new tab) ) -> string (opens in a new tab)

Returns an array containing the superclass ancestry, the last index in this array will always be <<<ROOT>>> since that's the base class for everything under the Roblox engine.

	local workspaceSuperclasses = ClassIndex.GetClassSuperclasses("Workspace")
 
	print(workspaceSuperclasses) -- { "WorldRoot", "Model", "PVInstance", "Instance", "`<<<ROOT>>>`" }