Never require a module or a service again with the "modular" plugin!

showcase1

modular is an open-source plugin that make scripting way easier by tracking every module and service in your game and suggesting them as an autoComplete option.

Features :

Download :

The plugin link : https://create.roblox.com/store/asset/18695860600/modular-v1

Source code here

local ScriptEditorService = game:GetService("ScriptEditorService")
local Modules = {}
local Services = {"AdService", "AnalyticsService", "AssetService", "BadgeService", "ChangeHistoryService", "Chat", "CollectionService", "ContextActionService", "CookiesService", "CoreGui", "CorePackages", "CoreScriptSyncService", "DataStoreService", "Debris", "EventIngestService", "FriendService", "GamepadService", "GamePassService", "Geometry", "GroupService", "GuiService", "HapticService", "HttpRbxApiService", "HttpService", "InsertService", "KeyframeSequenceProvider", "LocalizationService", "LogService", "MarketplaceService", "MessagingService", "NavigationService", "NetworkClient", "NetworkServer", "NotificationService", "PathfindingService", "PhysicsService", "Players", "PointsService", "PolicyService", "ProximityPromptService", "RenderSettings", "ReplicatedStorage", "RobloxScriptSecurity", "TeleportService", "ReplicatedFirst", "RunService", "ScriptContext", "Selection", "ServerScriptService", "ServerStorage", "SocialService", "SoundService", "StarterCharacterScripts", "StarterGui", "StarterPack", "StarterPlayer", "StarterPlayerScripts", "StudioService", "Teams", "TeleportService", "TestService", "TextService", "TweenService", "UserInputService", "UserService", "VRService", "VoiceChatService", "Workspace"}
local Locations = {Workspace = game:GetService("Workspace"),Players = game:GetService("Players"),Lighting = game:GetService("Lighting"),ReplicatedStorage = game:GetService("ReplicatedStorage"),ServerStorage = game:GetService("ServerStorage"),StarterPlayer = game:GetService("StarterPlayer"),StarterCharacterScripts = game:GetService("StarterCharacterScripts"),StarterGui = game:GetService("StarterGui"),StarterPack = game:GetService("StarterPack"),	Teams = game:GetService("Teams"),SoundService = game:GetService("SoundService"),Chat = game:GetService("Chat"),ServerScriptService = game:GetService("ServerScriptService"), ReplicatedFirst = game.ReplicatedFirst }

function addModule(module : ModuleScript)
	if module == nil then return end
	
	local path = "local "..module.Name.." = require(game."..module:GetFullName()..")"
	
	
	local function register(request : Request, response : Response)
		local temp = nil

		for _, item in ipairs(response.items) do
			if item.textEdit then
				temp = table.clone(item.textEdit.replace)
				break
			end
		end

		if not temp then return response end

		local item = {
			label = module.Name;
			detail = "Requires "..module.Name;
			kind = Enum.CompletionItemKind.Text;
			textEdit = {
				newText  = path;
				replace = temp
			}
		}

		table.insert(response.items, item)

		return response
	end
	local s, e = pcall(function()
		ScriptEditorService:RegisterAutocompleteCallback(module.Name, 1, register)
	end)
	
	if not s then
		ScriptEditorService:DeregisterAutocompleteCallback(module.Name)
		ScriptEditorService:RegisterAutocompleteCallback(module.Name, 1, register)
	end
end

function addService(service : string)
	if service == nil then return end
	
	local path = "local "..service.." = game:GetService('"..service.."')"
	

	local function register(request : Request, response : Response)
		local temp = nil

		for _, item in ipairs(response.items) do
			if item.textEdit then
				temp = table.clone(item.textEdit.replace)
				break
			end
		end

		if not temp then return response end
		
		local item = {
			label = service;
			detail = "Requires "..service;
			kind = Enum.CompletionItemKind.Module;
			textEdit = {
				newText  = path;
				replace = temp
			}
		}

		table.insert(response.items, item)

		return response
	end
	local s, e = pcall(function()
		ScriptEditorService:RegisterAutocompleteCallback(service, 1, register)
	end)

	if not s then
		ScriptEditorService:DeregisterAutocompleteCallback(service)
		ScriptEditorService:RegisterAutocompleteCallback(service, 1, register)
	end
end

function saveModule(module : ModuleScript)
	if module:IsA("ModuleScript") and table.find(Modules, module) == nil then
		table.insert(Modules, module)
		addModule(module)
	end
end

function removeModule(module : ModuleScript)
	if module:IsA("ModuleScript") and table.find(Modules, module) ~= nil then
		table.remove(Modules, table.find(Modules, module))
		local s, e = pcall(function()
			ScriptEditorService:DeregisterAutocompleteCallback(module.Name)
		end)
	end
end

for _, service : string in pairs(Services) do
	addService(service)
end

for _, location : Folder in pairs(Locations) do
	location.DescendantAdded:Connect(function(c)
		saveModule(c)
	end)

	location.DescendantRemoving:Connect(function(c)
		removeModule(c)
	end)

	for _, module in pairs(location:GetDescendants()) do
		saveModule(module)
	end
end

for _, module in pairs(Modules) do
	module:GetPropertyChangedSignal("Name"):Connect(function()
		removeModule(module)
		addModule(module)
	end)
end

Conclusion :

Hopefully you liked this resource, it took a week to get done. Please if you have any feedback let me know in the comments! This module was made by @gianfragolo , big thanks to @RyosWill too!.

IMPORTANT: IF IT DOSEN’T WORK RE-OPEN THE GAME AND CHECK FOR UPDATES!!

10 Likes

why the list of services instead of just using the game’s children?

1 Like

most likely due to loading issues

1 Like

Also there is an unused variable at line 6 that can error

I downloaded it but can’t get it to work is there anything else you need to do to set it up?

1 Like

didnt work for me either, what does work for me and has more features is @flowAces’s auto complete plugin

1 Like

Update the module now everything works

Update the module now everything works, try re-opening the game also. I am aware that others similiar plugin works, but my goal for this one is to be simple and track module instances

There are many plugins that does this

Even my own open source plugin that does this better
I don’t see a reason to use this

I mean, if you dont want to use it its fine, but at least give me an actual feedback to improve my creation not just saying “mine is better”. Plus i dont know what plugin are you talking about, if you will send me a link i will check it out and see the difference

4 Likes

I apologize. Here are some suggestions: Add a prefix (trust me, you will add it in the future). And add a feature to require multiple modules at once. Like my plugin does:

Please note that my plugin might have some errors because it is my first plugin.

Dude your module has nothing to do with auto completion its indeed another snippet plugin. My plugin does another thing that has nothing to do with snippets. Did you at least read the entire post? And why using a snippets? Its just less-user friendly tbh

1 Like

“Dude” it does the exact same thing

No it does not. Your plugin stores pecies of code that people use often. My plugin, while you code, suggests you as an autocomplete option (screenshots of the main post) every service (ex. UserInputService) but it also keep track of modules and will suggest you each module in your project as well.

Wait where? Are you talking about the code or abt the post??