Get the focused ScriptDocument or LuaSourceContainer

I have been trying to make a plugin that lets me automatically format parts of my code in a specific way by pressing a hotkey while I am editing a script.

However there is one massive hole in the Script Editor API which prevents me from creating this plugin: there is no way of figuring out which script the user is currently interacting with.

I can get all the open scripts, but that’s useless for this. I can force the user to select the script in the explorer, but that’s just bad. There are heuristics that can be used (such as listening to ScriptEditorService.TextDocumentDidChange) but they are insufficient.

its already a thing; StudioService.ActiveScript

2 Likes

Great, thanks heaps :slight_smile: I wish these things were more clearly documented.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.