Flesh out remodel migration page

This commit is contained in:
Filip Tibell 2023-07-22 22:55:41 +02:00
parent 55f51a7844
commit a09bbfd363
No known key found for this signature in database

View file

@ -9,7 +9,8 @@ Lune.
## Drop-in Compatibility ## Drop-in Compatibility
This guide provides a module which translates all of the relevant Lune APIs to their Remodel This guide provides a module which translates all of the relevant Lune APIs to their Remodel
equivalents. equivalents. For more details or manual migration steps, check out
[Differences Between Lune & Remodel](#differences-between-lune--remodel) below.
<Steps> <Steps>
@ -25,9 +26,9 @@ Copy the source below and place it in a file named `remodel.luau`:
local fs = require("@lune/fs") local fs = require("@lune/fs")
local net = require("@lune/net") local net = require("@lune/net")
local serde = require("@lune/serde")
local process = require("@lune/process") local process = require("@lune/process")
local roblox = require("@lune/roblox") local roblox = require("@lune/roblox")
local serde = require("@lune/serde")
export type LuneDataModel = roblox.DataModel export type LuneDataModel = roblox.DataModel
export type LuneInstance = roblox.Instance export type LuneInstance = roblox.Instance
@ -343,27 +344,75 @@ lune example
</Steps> </Steps>
## API Differences ## Differences Between Lune & Remodel
Since Lune is meant to be a general-purpose Luau runtime, it takes a different approach from Remodel Most APIs previously found in Remodel have direct equivalents in Lune, below are some direct links
in certain areas: to APIs that are equivalent or very similar.
- Lune uses Luau instead of Lua 5.3. <details>
- APIs are more loosely coupled, for example reading a Roblox place file is separated into two <summary>Places & Models</summary>
steps - reading the actual file using Lune's `fs` built-in library, and then deserializing that
file using the `roblox` built-in library. - `remodel.readPlaceFile` ➡ [`fs.readFile`](../api-reference/fs.md#readfile) &
- Lune tries to support many more formats and use cases - while Remodel has the `JSON` global for [`roblox.deserializePlace`](../api-reference/roblox.md#deserializeplace)
converting to/from JSON specifically, Lune has the `serde` built-in library which can convert - `remodel.readModelFile` ➡ [`fs.readFile`](../api-reference/fs.md#readfile) &
to/from JSON, YAML, TOML, compress and decompress files, and more. [`roblox.deserializeModel`](../api-reference/roblox.md#deserializemodel)
- `remodel.readPlaceAsset` ➡ [`net.request`](../api-reference/net.md#request) &
[`roblox.deserializePlace`](../api-reference/roblox.md#deserializeplace)
- `remodel.readModelAsset` ➡ [`net.request`](../api-reference/net.md#request) &
[`roblox.deserializeModel`](../api-reference/roblox.md#deserializemodel)
- `remodel.writePlaceFile` ➡ [`roblox.serializePlace`](../api-reference/roblox.md#serializeplace)
& [`fs.writeFile`](../api-reference/fs.md#writefile)
- `remodel.writeModelFile` ➡ [`roblox.serializeModel`](../api-reference/roblox.md#serializemodel)
& [`fs.writeFile`](../api-reference/fs.md#writefile)
- `remodel.writeExistingPlaceAsset` ➡
[`roblox.serializePlace`](../api-reference/roblox.md#serializeplace) &
[`net.request`](../api-reference/net.md#request)
- `remodel.writeExistingModelAsset` ➡
[`roblox.serializeModel`](../api-reference/roblox.md#serializemodel) &
[`net.request`](../api-reference/net.md#request)
- `remodel.getRawProperty` ➡ no equivalent, you can get properties directly by indexing
- `remodel.setRawProperty` ➡ no equivalent, you can set properties directly by indexing
</details>
<details>
<summary>Files & Directories</summary>
- `remodel.readFile` ➡ [`fs.readFile`](../api-reference/fs.md#readfile)
- `remodel.readDir` ➡ [`fs.readDir`](../api-reference/fs.md#readdir)
- `remodel.writeFile` ➡ [`fs.writeFile`](../api-reference/fs.md#writefile)
- `remodel.createDirAll` ➡ [`fs.writeDir`](../api-reference/fs.md#writedir)
- `remodel.removeFile` ➡ [`fs.removeFile`](../api-reference/fs.md#removefile)
- `remodel.removeDir` ➡ [`fs.removeDir`](../api-reference/fs.md#removedir)
- `remodel.isFile` ➡ [`fs.isFile`](../api-reference/fs.md#isfile)
- `remodel.isDir` ➡ [`fs.isDir`](../api-reference/fs.md#isdir)
</details>
<details>
<summary>JSON</summary>
- `json.fromString` ➡ [`serde.decode`](../api-reference/serde.md#decode)
- `json.toString` ➡ [`serde.encode`](../api-reference/serde.md#encode)
- `json.toStringPretty` ➡ [`serde.encode`](../api-reference/serde.md#encode)
</details>
Since Lune is meant to be a general-purpose Luau runtime, there are also some more general
differences, and Lune takes a different approach from Remodel in certain areas:
- Lune runs Luau instead of Lua 5.3.
- APIs are more loosely coupled, meaning that a task may require more steps using Lune. This also
means that Lune is more flexible and supports more use cases.
- Built-in libraries are not accessible from global variables, you have to explicitly import them - Built-in libraries are not accessible from global variables, you have to explicitly import them
using `require("@lune/library-name")`. using `require("@lune/library-name")`.
- Arguments given to the script are not available in `...`, you have to import them using the - Arguments given to scripts are not available in `...`, you have to use
`process` library: [`process.args`](../api-reference/process.md#args) instead.
- Lune generally supports all of the Roblox datatypes that are gettable/settable on instance
properties. For a full list of available datatypes, check out the
[API Status](./4-api-status.md) page.
```lua copy ---
local process = require("@lune/process")
print(process.args) -- Same as print(...) in Remodel There may be more differences than are listed here, and the Lune-specific guides and examples may
``` provide more info, but this should be all you need to know to migrate from Remodel. Good luck!
There are many more subtle differences between the two, not all of which are listed here.