I am working on a workflow with Rojo and Remodel so that I can also manage model assets through Github. I’ve come up with this workflow, but it seems a bit tedious and has some issues. What am I doing wrong? Is there a better way to do this?
Step 1. (only done the 1st time) I open my production place and gather all model files to insert into my repo.
-- init.lua
local game = remodel.readPlaceAsset("7472450623")
local function recursiveSave(folder, currentPath)
for _,object in ipairs(folder:GetChildren()) do
if object.ClassName == "Folder" then
local newPath = currentPath.."/".. object.Name
remodel.createDirAll(newPath)
recursiveSave(object, newPath)
elseif object.ClassName ~= "Camera" and object.ClassName ~= "Script" and object.ClassName ~= "LocalScript" and object.ClassName ~= "ModuleScript" then
remodel.writeModelFile(object, currentPath .. "/" .. object.Name .. ".rbxm")
end
end
end
local directories = {
["Workspace"] = game.Workspace,
["ServerScriptService"] = game.ServerScriptService,
["StarterPlayer/StarterPlayerScripts"] = game.StarterPlayer.StarterPlayerScripts,
["ServerStorage"] = game.ServerStorage,
["ReplicatedStorage"] = game.ReplicatedStorage,
["StarterGui"] = game.StarterGui,
["ReplicatedFirst"] = game.ReplicatedFirst,
["Lighting"] = game.Lighting,
["SoundService"] = game.SoundService
}
for name,dir in pairs(directories) do
print("[SCANNING]: ", name)
local path = "../Lobby/src/" .. name
remodel.createDirAll(path)
recursiveSave(dir, path)
end
Step 2. From here I can sync my Rojo to the place and do normal script changes in VS Code, then make asset changes in either VS Code or in Roblox Studio.
Step 3. When I’m done I run a batch file to delete all the model files in my repo, then replace them by reading the Roblox Studio place file to account for changed, deleted, or added models.
SET mypath=%~dp0
remodel run .\pull_models.lua
-- pull_models.lua
local game = remodel.readPlaceFile("../PlaceFiles/LocalPlaceFile.rbxl")
local function recursiveSave(folder, currentPath)
for _,object in ipairs(folder:GetChildren()) do
if object.ClassName == "Folder" then
local newPath = currentPath.."/".. object.Name
remodel.createDirAll(newPath)
recursiveSave(object, newPath)
elseif object.ClassName ~= "Camera" and object.ClassName ~= "Script" and object.ClassName ~= "LocalScript" and object.ClassName ~= "ModuleScript" then
remodel.writeModelFile(object, currentPath .. "/" .. object.Name .. ".rbxm")
end
end
end
local function recursiveRemove(object, currentPath)
local isFolder = string.find(object, "%.") == nil
local isModelFile = string.find(object, ".rbxm") ~= nil
if isFolder then
currentPath = currentPath.."/"..object
local folder = remodel.readDir(currentPath)
for _,child in pairs(folder) do
recursiveRemove(child, currentPath)
end
elseif isModelFile then
os.remove(currentPath.."/"..object)
end
end
local directories = {
["Workspace"] = game.Workspace,
["ServerStorage"] = game.ServerStorage,
["ReplicatedStorage/Assets"] = game.ReplicatedStorage.Assets,
["ReplicatedStorage/Values"] = game.ReplicatedStorage.Values,
["StarterGui"] = game.StarterGui,
["ReplicatedFirst"] = game.ReplicatedFirst,
["Lighting"] = game.Lighting,
["SoundService"] = game.SoundService
}
for name,dir in pairs(directories) do
local path = "../Lobby/src/" .. name
local folder = remodel.readDir(path)
for _,child in pairs(folder) do
recursiveRemove(child, path)
end
print("[SCANNING]: ", name)
remodel.createDirAll(path)
recursiveSave(dir, path)
end
Step 4. I then commit these changes on a branch
From here, if I want to open up the place again, I would pull any changes from GitHub, then sync my Rojo to the place. If I make more asset changes I would need to repeat step 4.
Issues:
-
It appears as though some asset types like Attachments and WeldConstraints do not have their properties correctly saved/synced. I tried playing a map in which WeldConstraints and RopeConstraints were used to hold lanterns, but they were missing their Part0 / Part1 properties, so the lantern just fell apart. Also, some of the weapons in the game rely on Attachments which were missing or had wrong properties.
-
This seems like a really tedious process, is there any better way to fully manage a project with Rojo, Remodel, and Github?