Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Reorder writeModelFile / writePlaceFile parameters (#81)
Browse files Browse the repository at this point in the history
* Reorder writeModelFile / writePlaceFile parameters

* Update changelog

Co-authored-by: [email protected] <[email protected]>
Qualadore and [email protected] authored Aug 4, 2022
1 parent 1b73ef2 commit 0b73947
Showing 12 changed files with 15 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Remodel Changelog

## Unreleased Changes
* **Breaking:** Reordered parameters of `remodel.writeModelFile` and `remodel.writePlaceFile` to accept path first, then content ([#81](https://github.com/rojo-rbx/remodel/pull/81)).

## 0.10.0 (2022-06-13)
* Switched from `rlua` to `mlua`, which should improve Lua performance slightly. ([#73])
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ local Models = game.ReplicatedStorage.Models

for _, model in ipairs(Models:GetChildren()) do
-- Save out each child as an rbxmx model
remodel.writeModelFile(model, "models/" .. model.Name .. ".rbxmx")
remodel.writeModelFile("models/" .. model.Name .. ".rbxmx", model)
end
```

@@ -123,7 +123,7 @@ Throws on error.

### `remodel.writePlaceFile`
```
remodel.writePlaceFile(instance: DataModel, path: string)
remodel.writePlaceFile(path: string, instance: DataModel)
```

Saves an `rbxlx` file out of the given `DataModel` instance.
@@ -134,7 +134,7 @@ Throws on error.

### `remodel.writeModelFile`
```
remodel.writeModelFile(instance: Instance, path: string)
remodel.writeModelFile(path: string, instance: Instance)
```

Saves an `rbxmx` or `rbxm` (0.4.0+) file out of the given `Instance`.
2 changes: 1 addition & 1 deletion examples/01-load-and-save.lua
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@ local stringValue = root:FindFirstChild("String")
print("Found string value: ", stringValue.Name)

-- We can save models back to disk with remodel.writeModelFile
remodel.writeModelFile(stringValue, "temp/just-a-stringvalue.rbxmx")
remodel.writeModelFile("temp/just-a-stringvalue.rbxmx", stringValue)
2 changes: 1 addition & 1 deletion examples/02-extract-models.lua
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ local Models = game.ReplicatedStorage.Models
remodel.createDirAll("temp/models")

for _, model in ipairs(Models:GetChildren()) do
remodel.writeModelFile(model, "temp/models/" .. model.Name .. ".rbxmx")
remodel.writeModelFile("temp/models/" .. model.Name .. ".rbxmx", model)
end

-- And that's it!
2 changes: 1 addition & 1 deletion examples/04-move-terrain.lua
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@ local outputGame = remodel.readPlaceFile("output-place.rbxlx");
outputGame.Workspace.Terrain:Destroy()
inputGame.Workspace.Terrain.Parent = outputGame.Workspace

remodel.writePlaceFile(outputGame, "output-place-updated.rbxlx")
remodel.writePlaceFile("output-place-updated.rbxlx", outputGame)
4 changes: 2 additions & 2 deletions src/remodel_api/remodel.rs
Original file line number Diff line number Diff line change
@@ -496,7 +496,7 @@ impl UserData for Remodel {

methods.add_function(
"writePlaceFile",
|_context, (instance, lua_path): (LuaInstance, String)| {
|_context, (lua_path, instance): (String, LuaInstance)| {
let path = Path::new(&lua_path);

match path.extension().and_then(OsStr::to_str) {
@@ -512,7 +512,7 @@ impl UserData for Remodel {

methods.add_function(
"writeModelFile",
|_context, (instance, lua_path): (LuaInstance, String)| {
|_context, (lua_path, instance): (String, LuaInstance)| {
let path = Path::new(&lua_path);

match path.extension().and_then(OsStr::to_str) {
2 changes: 1 addition & 1 deletion test-scripts/rojo.lua
Original file line number Diff line number Diff line change
@@ -13,4 +13,4 @@ local project = {

local tree = rojo.buildProject(project)

remodel.writeModelFile(tree, "temp/rojo-output.rbxmx")
remodel.writeModelFile("temp/rojo-output.rbxmx", tree)
2 changes: 1 addition & 1 deletion test-scripts/set-parent-nil.lua
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ stringValue.Parent = nil
assert(stringValue.Parent == nil)
assert(root:FindFirstChild("String") == nil)

remodel.writeModelFile(stringValue, "temp/written-from-nil.rbxmx")
remodel.writeModelFile("temp/written-from-nil.rbxmx", stringValue)

local reloaded = remodel.readModelFile("temp/written-from-nil.rbxmx")[1]

2 changes: 1 addition & 1 deletion test-scripts/write-model-binary.lua
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ assert(root.Name == "Example Model")
local module = root:FindFirstChild("SomeModule")
assert(module.ClassName == "ModuleScript")

remodel.writeModelFile(module, "temp/just-module.rbxm")
remodel.writeModelFile("temp/just-module.rbxm", module)

local module2 = remodel.readModelFile("temp/just-module.rbxm")[1]
assert(module2.ClassName == "ModuleScript")
2 changes: 1 addition & 1 deletion test-scripts/write-model.lua
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ assert(root.Name == "Root")

local stringValue = root:FindFirstChild("String")

remodel.writeModelFile(stringValue, "temp/just-stringvalue.rbxmx")
remodel.writeModelFile("temp/just-stringvalue.rbxmx", stringValue)

local stringValue2 = remodel.readModelFile("temp/just-stringvalue.rbxmx")[1]
assert(stringValue2.Name == "String")
2 changes: 1 addition & 1 deletion test-scripts/write-place-binary.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local game = remodel.readPlaceFile("test-models/place-with-models-binary.rbxl")
assert(game.Workspace.Camera ~= nil)

remodel.writePlaceFile(game, "temp/new-place-binary.rbxl")
remodel.writePlaceFile("temp/new-place-binary.rbxl", game)

local game2 = remodel.readPlaceFile("temp/new-place-binary.rbxl")
assert(game2.Workspace.Camera ~= nil)
2 changes: 1 addition & 1 deletion test-scripts/write-place.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local game = remodel.readPlaceFile("test-models/place-with-models.rbxlx")
assert(game.Workspace.Camera ~= nil)

remodel.writePlaceFile(game, "temp/new-place.rbxlx")
remodel.writePlaceFile("temp/new-place.rbxlx", game)

local game2 = remodel.readPlaceFile("temp/new-place.rbxlx")
assert(game2.Workspace.Camera ~= nil)

0 comments on commit 0b73947

Please sign in to comment.