Plugin File Exporting

As a Roblox developer, it is currently impossible to export custom files from a plugin.

If Roblox is able to address this issue, it would improve my development experience because it would allow me to both import, and export data from a plugin.

This would allow for the use of plugins as full on file editors, would allow plugins to export presets and other information for users to share, and would allow for a ton of other super useful plugins to be created.

I propose a function to go alongside StudioService:PromptImportFile() and StudioService:PromptImportFiles(), e.g. StudioService:PromptExportFile(filetypes, fileContent), it could have identical behavior, except, rather than importing, it simply exports.

Old request

As a Roblox developer, it is currently not possible to prompt to export files from studio.

If Roblox is able to address this issue, it would improve my development experience because it would allow me to write plugins which can both produce and accept large data sets, create file formats for my plugins, and more.

Here is a basic example of where this would be useful. Say you want to both import and export a script using a plugin. You can use local scriptFile = StudioService:PromptImportFile({"lua"}) to import it fairly easily.

Well, what if you then want to allow the user to save that script? At the moment the only way to get large data out of studio is to print it large pieces at a time and have the user copy and paste which means little to no binary content can safely be used, and large files can take extremely long amounts of time. Having the ability to prompt the user to save the file to the same location they loaded it from (or another location) would completely solve this.

For example, scriptFile:PromptExport({"lua"}, contents) could prompt the user to save the file at its original path, allowing the .lua extension, and then automatically update the scriptFile object. Additionally, maybe you might want to prompt the export of a random file you haven’t yet imported, so having something like someFile = StudioService:PromptExportFile({"lua"}, contents) would be perfect.

I think that the use cases of exporting files are not as clear as importing may be, but I think that the ability to import and export files is necessary for one or the other to be useful to plugins. Here are a couple examples of where exporting could be used in plugins where importing would be nearly useless otherwise:

  1. Some sort of game patching plugin which could both Export patches and Import them to apply them to a game. This could allow a developer to even create a modding or submissions system for their games and allow users to send them files which the developer can completely automatically add to their game.
  2. The ability to create Settings Presets and easily import and export studio settings.
  3. The ability to create Script Editor Theme files that can be imported and exported much much easier. A plugin has done this before, but they did it by having the user copy and share long strings with each other, and the plugin which did this has since gone off sale.
  4. Really the ability to just import or export any kind of setting presets or large sets of data, such as settings for the plugin itself.
39 Likes

To anyone who might be searching for this: After some digging, the closest thing I’ve found to this feature is this:
https://developer.roblox.com/en-us/api-reference/function/Plugin/PromptSaveSelection

I wanted to export “.md” files (markdown), but looks like we’re limited to .lua, .rbxm, or .rbxmx files. :weary:
(You can export .lua files if you’re exporting a singular script. There might be other file types that I’m not aware of.)

There are probably security-related reasons why Roblox restricts export file types.

10 Likes

That function is unfortunately only meant for exporting instances. It would be handy if Studio whitelisted a few dozen common or speculatively useful file extensions like .json, .config, .md, .txt, etc. with the proposed function. Less confusing and more intuitive than exporting .lua all the time for example, and there are fewer manual steps involved after generating the files to be able to use them. I think avoiding images and potentially executable file extensions is a no-brainer though.

Being able to share presets and other plugin data with other users without having to force the user to copy and paste things out of a textbox or output, or go find their plugin settings would be great for building more user friendly plugins.

9 Likes

This unfortunately doesn’t work for binary datastreams, since script files are plaintext and also Studio hates the NUL byte.

I’m sort of bumping this because I still want this to be implemented. Even with plaintext exports, its a bit counter intuitive to have the user change the file extension just to make the file open where it’s meant to be used.

The easiest solution, as Caz suggested, is to allow a batch of file extensions but nothing else, but I still think binary exporting would be useful.

4 Likes

I know this is quite an old topic, but, another very important problem with using scripts to prompt exports is that scripts can only contain 200k characters. Anything that is crunching data is going to have a hard time.

It’s odd to me that you can import files but you can’t export them, exporting data from studio would be so useful.


I will say, the only concerns I can see are the ability for plugins to ask the user to export and run malicious files. However, plugins can just as easily already do this by simply asking the user to create the file themselves. It’s not much different from any other malicious form of user prompting. I think it’s also sufficient like what was being said above to limit users to exporting certain generic formats, for example, .bin, .txt, .md, .json, .csv, .lua.

Problems with using scripts:

  • Confusing
  • Limited to 200kb
  • Doesn’t support binary data
  • Requires inserting a script (requiring plugin permissions)

Problems with using autofocus textboxes & having the user copy:

  • Limited to 16kb (even worse!)
  • Doesn’t support binary data
  • Requires the user to figure out their own way to get the data around

Lastly let me provide some practical use cases for file exports I have seen currently in use:

  • Exporting performance benchmark information
  • Exporting DataStore content (Like the DataStore Editor plugin)
  • Custom creations being exported from studio and loaded in games (e.g. via pastebin or GitHub gists)
  • Generic data processing (Studio might be for Roblox development but sometimes data processing can be super useful, especially with so many external Roblox tools out there)
4 Likes

I’m bringing this up again because PromptImportFile seems half-finished if we cant also export files.

My main reasoning is creating a plugin that can export a file, ie, animation track data, that can be shared to other people. This would be more intuitive than other workarounds that exist (copying data in a textbox, for example).

The issue is mainly, again, this feature seems half-baked. Open up the File instance, flesh it out into a full feature where I can also create them, change their buffer, and save them. I assume the File is a clone of the already existing data so no data gets overwritten and for other sandboxing reasons.

Also please make is so I can flush files out of memory when I’m done with them, this alone at least.

5 Likes