RBXport - Convert place files into RbxRefresh projects

I made a nifty little tool called RBXport. It is a Lua script you can run on your computer to parse rbxlx files and convert them into an RbxRefresh Visual Studio Code project. It has no dependencies, and is only 413 source lines of code at the time of writing. If you want to salvage its components for your own purposes, I will describe how it works after I describe how to use it.

Setup and use

  1. Navigate to the GitHub repository and copy the Lua source and paste it into a file (or download it, if you are a civilized human bean). We will refer to this file as RBXport.lua.

  2. Open up a command line and cd to the proper directory.

    To open a command prompt, type cmd into the Windows start menu search. To change the working directory to the Desktop, you would type cd Desktop (and press enter) and this would change directory (hence cd) to the Desktop. Type ls (and press enter) to view the files under the working directory. If you don’t know what you are doing, make sure your RBXport.lua file is on the Desktop so you can easily cd there.
  3. Run lua RBXport.lua PATH_TO_FILE.rbxlx FOLDER_PATH_TO_WRITE_TO (works much better with LuaJIT).

    If you don’t already have Lua installed on your computer, and don’t know how to compile Lua, grab a pre-compiled file here. Right click on it and press the extract files option. Open up the extracted folder and open up the “Bin” folder inside. Next, click on the top bar which displays the directory (without clicking one of the folders) to select the entire directory string and copy it to your clipboard. Then type “path” into the windows search, click “environment variables”. In the window that appears there will be a scroller that has a variable name of Path. Click it, then hit the “edit” button. Then hit “new”, and paste in the directory. This is called “adding Lua to your path” if you have never done anything like this before.
  4. Open up your glorious new RbxRefresh project!

How it works

This project was written for RbxRefresh simply because it is the most flexible on allowing you to sync in Scripts which are parented to Guis/Models/etc. It is also very easy to use. Just open up the project with Visual Studio Code and hit Ctrl+Shift+B (after it is already installed). However, this project can easily be ported to work for other tools or other use cases so I thought I’d share.

RBXport first calls its MakeTree function, which parses the xml data and returns a table full of all the objects in the game parsed with all of their properties as string members. Every object has an array inside it under Object.Children which holds all the children. In essence, it creates a Lua table representation of all the Objects and all of their properties, which is then given to my very simple BuildProject function which recursively iterates through every object’s children and generates an RbxRefresh project from the data. The data could just as easily be used for whatever you want.

Things to note

  • Currently, Axes and BinaryString lack an implementation because I don’t know how the data from these should be interpreted. No Axes means ArcHandles Objects will not contain all of the data necessary to recreate them. No BinaryStrings means that Objects will contain no data about what (CollectionService) Tags they have. These don’t really matter for what I was using the project for, but feel free to submit a PR if you understand things I do not.
    • These placeholder functions take in two parameters: (Next, Closer). Closer is a string, which in this case would be “/Axes” and “/BinaryString” respectively (not necessary in this case where it can be hardcoded, but helps me reuse functions like SingleLiteral). Next is a stateful function which advances the XML parser. It returns Value, Type, where Type is “Tag” or “Literal” and Value is a string of whatever the parser is currently on, excluding the signs <> surrounding signs. This information can also be read here
  • PhysicalProperties are in their own table (of the same name) instead of being dumped into the rest of the object’s properties
  • Right now it only supports Windows but could easily be adjusted for Macs. Submit a PR.

Out of curiosity, what version of Lua was this made for? I assume Lua 5.1, but I thought I would ask.

It should work for 5.1 and later and LuaJIT, so pretty much any version of Lua.

1 Like

I’m trying to use this but it isn’t instantiating any scripts. Am I doing something wrong?

The only computer I have run this on is my own, so I am unsure. Were there any errors? This is completely open source so whatever doesn’t work should hopefully be fixable by the user.

Here is the code that writes to Lua files. It should be pretty straightforward.

Impressive work. Definitely worth trying out for those people still skeptical.

Digressing, welcome to the forum! It’s good to have new members like you who strive to help the community!