LBA (Luau Bytecode Analyzer) Plugin

Summary

This plugin allows you to compile your scripts through the command line, and view their disassembly (bytecode). The primary uses of this plugin are learning and code optimization.

Usage

This plugin works entirely from the Roblox Studio Command line. If you aren’t familiar with it, here it is:
Command Line
Once you’ve enabled the command line, all you have to do is open up the script that you wish to compile, then type in “–bytecode”. This will open a window that displays the bytecode contents of your script (see below for example):

Flags

If you have used any command line interface before, you might be familiar with flags, which are special arguments used to modify the behavior of a command. This plugin comes with three flags, all specified below (note, flags are order-independent and case-sensitive):

Disables syntax highlighting, default: false

-nhl

The optimization level at which the compiler will be ran, default: 2

-O0, -O1, -O2

This will output the bytecode into a module script in ServerStorage (in case you want to copy and paste it)
NOTE: This will only work if the length of the bytecode is <= 200,000 characters (Roblox limitation). Ideally, nobody will have an issue with this, but if you do: please let me know so I can update the plugin to work around this limitation.

-mout

Example usages of --bytecode with a flag:

(This will run the bytecode compiler then display without syntax highlighting)

--bytecode -nhl

(This will run the bytecode compiler at optimize level 0)

--bytecode -O0

(This will run the bytecode compiler at optimize level 1 then display without syntax highlighting)

--bytecode -nhl -O1
Additional Notes

When you attempt to use the plugin, it might ask you this:


Just make sure to click “Allow” as the plugin needs to access an externally hosted Luau compiler to function.

When you attempt to use the plugin with the “-mout” flag, it will ask for script injection privileges. Without these privileges, the plugin will fail to create and output a module script to ServerStorage.

Download

26 Likes

I like this a lot! Much more ergonomic and informative than the luau-compile CLI tool.

Is the backend open source?

I don’t plan on open sourcing the actual server code, but in a gist it just receives a post request with the source code, compiles it using luau-compile v0.684, then returns the bytecode in human readable form (which is then formatted and highlighted on the Roblox Studio client).

4 Likes

Update:

  • Added the -mout flag, which allows you to export bytecode into a module script so you can copy and paste, edit it, or export it.

Limitations:

  • The -mout flag will only work if the bytecode is <= 200,000 characters in size (Roblox limitation). This can be worked around, but I have intentionally not implemented this yet, as I believe it to be unnecessary. If anyone does need to export bytecode of this size, please let me know so I can update the plugin accordingly.
1 Like

Hi @xDom, :waving_hand:

I’m really interested in understanding how a plugin like yours can detect and parse input from the command bar that would normally just be treated as a comment? I love this minimal functionality and I’m curious how you’re accepting those flags! :person_raising_hand:

Thanks!

Cool in concept, but no.

I want to look at ByteCode but I’d rather have to have a request to something I can inspect that’s open-source and hosted on my local machine. I would not be comfortable with this as we just have to take your word for it that the website does only compile the code (which is a HUGE security risk in and of itself).

This also might not class as open-source software and you’d likely need to go to Creations-And-Feedback due to the lack of an open-source backend.

Both free or open-source, as well as paid and closed-source resources may be posted about in this category. Please make sure your resources are relevant to Roblox development.

2 Likes

Fair enough, though I’d still not trust a proprietary webserver for this kind of complete access to place scripts.

Completely fair point, and couldn’t agree more. Just wanted to point out that this is the appropriate category regardless.

1 Like

If you are paranoid about that, you can run the disassembler from Roblox on your machine. I made a tutorial about it:

3 Likes

The only problem I have with this is that Vector3.new is the same exact thing as vector.create. Which can be inlined and fast-called. So it would really be a good feature if the Vector3.new operator was compiled to the same operation as the vector.create does

If you don’t want to share your source code with the server you can always download the luau compiler (GitHub - luau-lang/luau: A fast, small, safe, gradually typed embeddable scripting language derived from Lua) and just run it locally.

1 Like

I used the LogService. For more specific information you can look at the plugin source code (it should be in your Roblox Studio plugin files)

1 Like

Still not as comfortable as it being given directly as a plugin.