Plugin:PromptOpenFile(string filter = "*.*")

The Problem

As a Roblox developer, prompting users to input big files is currently over-complicated.

For the past few weeks I’ve been working on a plugin that imports Valve Map Files into Roblox, and currently the only way I can prompt the user to input the file is to open a script, and tell them to paste the file into the script:

image

Because these files can be several hundred thousand lines long, doing it like this tends to give the script editor a heart attack while it tries to syntax highlight the file:

Try to add binary files into the mix and… well, it gets a bit messy.
Roblox’s script editor “can” read it, but it REALLY does not enjoy trying to syntax highlight binary files. It takes almost 30 seconds for this script to be opened when double clicking it from the explorer!


A possible solution?

I would like to propose a new YieldFunction for plugins:

Tuple<bool,string> Plugin:PromptOpenFile(string filter = "*.*")

This YieldFunction would prompt the user to open a file with the specified filters.
The filter parameter would work like the Filter property found in the FileDialog class from the .NET framework:

Although the use cases for this might seem a bit slim, I think this would open the door to a wide variety of neat applications for plugins.

37 Likes

This would be incredibly useful for my height-map plugin as well. I was able to get it working alright using global tables and some java code, but it would be preferable to be able to prompt specific files instead.

2 Likes

Whoops, forgot to mention the return types!

The first returned value would be a boolean describing the success of the call. If an error occurs while trying to read the file, or the user exits the window without selecting anything, this would be false.

The second returned value would be a string either containing the contents of the file if it succeeded, or an error message indicating why the call wasn’t successful (maybe a blank string or nil if the user just cancelled it, so the plugin could properly distinguish when an actual error occurred or not).

2 Likes

This would be useful for lots of things. Also a way to export a file.

2 Likes

If this API were implemented, the creativity of plugin development would be drastically improved. So much to come of this.

4 Likes

Check these out:

https://developer.roblox.com/en-us/api-reference/function/StudioService/PromptImportFile
https://developer.roblox.com/en-us/api-reference/function/StudioService/PromptImportFiles
https://developer.roblox.com/en-us/api-reference/class/File

5 Likes