Script Source Color3 and BrickColor Previewer

This plugin displays color swatches in the margin of your script editor (if you dock the widget there) that correspond with Color3 and BrickColor constructors in the source code of your currently open script.

For a long time I’ve wanted Color3 previewing in scripts, and while working on my game recently I ran into a situation where not being able to do that really bothered me. So here we are.


Setup

This plugin is only used inside of the script editor.

You can add this plugin to your Quick Access Toolbar, create a hotkey, or use the plugin toolbar button.

Click on the button or use your hotkey while in a script to open the widget. Dock the widget left or right of the script editor (Right feels best for me).

image


Features

Previewing of Color3 and BrickColor

Previews are generated via loadstring , so short in-line calculations (e.g. 150/255 without parenthesis) will be correctly parsed.

  • Color3.new/fromRGB/fromHSV are supported.
  • All BrickColor constructor functions are also supported.

Multiple constructors on one line will be shown in the widget in the correct order.

This plugin uses loadstring but should be safe; the loadstring environment is limited to the math, string, BrickColor, Color3, and Random libraries.

Automatically Minimizes in Viewport

When you leave the script editor, the widget will close itself until you open another script to save you screen space.

If you intentionally close the widget, it will not reopen until you reopen it using the plugin button or your hotkey.

Automatically Updates Preview

The widget will regenerate the preview automatically, in real time.


Future

It would be cool to expand this into a general script previewer / overview tool with other things previewed, but I’m not sure what else to render other than color constructors and overall “code shape” (i.e. a code minimap). When I have more time I may look into this.

Feel free to suggest other things you’d like to see previewed out of your scripts.


Bugs

Existing bugs

  • In-line function calls and parenthesis-wrapped expressions are not parsed (e.g. Color3.new(math.sin(0.3)) or (150/255)). You currently cannot use parenthesis inside constructors.
  • It’s possible to make the widget show up in the viewport after starting and stopping a play solo session. This is non-destructive and it can be closed, ignored, or fixed by opening a script.

Reporting bugs

I’ve only tested this plugin in my own projects. Reply to this thread if you find a way to reliably break it. Remember to include reproduction steps or code that reproduces the issue.

25 Likes

I’ve updated this plugin to use newer API, and synchronize the scroll with the currently active script editor window. :+1:

The widget will always be in sync with the script your typing cursor is focused on.