merge ws/engines
This commit is contained in:
commit
8bd15840d8
66 files changed
+31751
-1331
No files matched your search
@@ -13,16 +13,16 @@ and the host notes. Each standard type has its own page:
|
||||
| [Audio](audio.md) | `Audio`, `Decoder` | WAV, FLAC, MP3, Ogg Vorbis, Opus, AAC, M4A, AIFF, AU, CAF, VOC, WavPack, APE, TTA, Musepack, AC-3, QOA, ADPCM, ADX, VAG, BRSTM |
|
||||
| [Music](music.md) | `Module`, `Midi` | MOD, S3M, XM, IT, MTM, 669, STM, ULT, OKT, MED, PTM, FAR, UMX, AHX / HVL, MIDI, MUS, XMI, HMP, SoundFont 2 |
|
||||
| [Video](video.md) | `VideoDecoder`, `Demuxer`, `Track`, `Packet` | MP4 / MOV, MKV / WebM, AVI, MPEG-TS / PS, Ogg Theora, FLV, FLI / FLC, Smacker, Y4M, H.264 |
|
||||
| [3D scenes](scene.md) | `Scene`, `Voxels` | glTF / GLB, OBJ, STL, PLY, FBX, Collada, 3MF, USDA, OFF, VOX, 3DS, MS3D, B3D, LDraw, LWO, .x, IQM, PMX / PMD, VRML, X3D, MD2, MD3, MDL, MD5, BSP, SMD |
|
||||
| [3D scenes](scene.md) | `Scene`, `Voxels` | glTF / GLB, OBJ, STL, PLY, FBX, Collada, 3MF, USDA, OFF, VOX, 3DS, MS3D, B3D, LDraw, LWO, .x, IQM, PMX / PMD, VRML, X3D, MD2, MD3, MDL, MD5, BSP, SMD, Godot TSCN / ESCN, Unreal T3D, ASE |
|
||||
| [Roblox](roblox.md) | `RbxTree` (`F.Rbx`), `Scene` | rbxm / rbxl, rbxmx / rbxlx, Roblox .mesh |
|
||||
| [CAD](cad.md) | `Cad` (STEP) | STEP (B-rep through a plug-in) |
|
||||
| [Fonts](font.md) | `Font` | TTF / OTF, WOFF, WOFF2, BMFont, BDF, PCF, PSF, FON, Type 1, EOT, Hershey |
|
||||
| [Archives](archive.md) | `Archive` | zip, tar, gzip, 7z, xz, zstd, Brotli, bzip2, PAK, WAD, GRP, VPK, MPQ, cpio, ar / deb, rpm, .Z, LZ4, ISO 9660, LHA, ARJ, Zoo, uu / yEnc / BinHex / MacBinary / AppleSingle, D64, ADF, FAT, CAB |
|
||||
| [Data](data.md) | plain values, `XmlNode`, `Date` | JSON, XML, YAML, TOML, CSV, INI, MessagePack, CBOR, plist |
|
||||
| [Archives](archive.md) | `Archive` | zip, tar, gzip, 7z, xz, zstd, Brotli, bzip2, PAK, WAD, GRP, VPK, MPQ, cpio, ar / deb, rpm, .Z, LZ4, ISO 9660, LHA, ARJ, Zoo, uu / yEnc / BinHex / MacBinary / AppleSingle, D64, ADF, FAT, CAB, Unity packages |
|
||||
| [Data](data.md) | plain values, `XmlNode`, `Date` | JSON, XML, YAML, TOML, CSV, INI, MessagePack, CBOR, plist, Godot `.tres` |
|
||||
| [Minecraft and voxels](voxel.md) | typed values, `Scene` + `Voxels` | NBT, SNBT, `.schem` / `.schematic` / `.litematic`, Anvil `.mca`, Qubicle `.qb` |
|
||||
| [Vector](vector.md) | `Vector` | SVG |
|
||||
| [Layered images](layered.md) | `Layered` | PSD, Aseprite, OpenRaster |
|
||||
| [Tile maps](tilemap.md) | `TileMap` | Tiled TMX / TMJ (+ TSX / TSJ tilesets) |
|
||||
| [Tile maps](tilemap.md) | `TileMap` | Tiled TMX / TMJ (+ TSX / TSJ tilesets), LDtk, Ogmo Editor 3 |
|
||||
| [Subtitles](subtitles.md) | `Subtitles`, `Cue` | SRT, WebVTT, ASS / SSA |
|
||||
| [Playlists](playlist.md) | `Playlist` | M3U / M3U8 (HLS), PLS, XSPF |
|
||||
|
||||
|
||||
@@ -456,6 +456,26 @@ local out = assert(F.save(cab, nil, { format = "cab", compression = "none" }))
|
||||
assert(F.archive.load(out):list()[1].method == "store")
|
||||
```
|
||||
|
||||
## Unity packages
|
||||
|
||||
A `.unitypackage` is a gzip'd tar of one folder per asset guid (`asset`, `asset.meta`, `pathname`). It loads as an
|
||||
Archive keyed by the asset paths, each `.meta` next to its asset as in a Unity project folder; folders are `dir`
|
||||
entries with their own `.meta`. Every entry carries its `guid`, and an asset's `preview` (when the package has a
|
||||
`preview.png`) is a function returning its bytes. Without a name the file is plain gzip (it unwraps to the tar of
|
||||
guid folders): pass a `.unitypackage` name or `format = "unitypackage"`. Any Archive saves as a package: guids come
|
||||
from `entry.guid`, then the `.meta` entry's `guid:` line, else the path's MD5; missing `.meta` files are made.
|
||||
|
||||
```luau
|
||||
local pack = F.format("unitypackage").new()
|
||||
pack:add("Assets/Scripts", "", { dir = true })
|
||||
pack:add("Assets/Scripts/Player.cs", "public class Player { }\n")
|
||||
local bytes = assert(F.save(pack))
|
||||
local back = assert(F.load(bytes, { name = "game.unitypackage" }))
|
||||
assert(back.format == "unitypackage")
|
||||
local meta = buffer.tostring(assert(back:read("Assets/Scripts/Player.cs.meta")))
|
||||
assert(string.match(meta, "guid: (%x+)") == back:list()[3].guid)
|
||||
```
|
||||
|
||||
## Formats
|
||||
|
||||
| Format | Read | Write | Notes |
|
||||
@@ -491,6 +511,7 @@ assert(F.archive.load(out):list()[1].method == "store")
|
||||
| C64 disks (`.d64`, `.d71`, `.d81`) | yes | yes | PETSCII names; no GEOS VLIR |
|
||||
| Amiga disks (`.adf`) | yes | - | OFS / FFS; no long-name (DOS 6 / 7) volumes |
|
||||
| FAT images (`.img`, `.ima`) | yes | yes | FAT12 / 16 / 32, VFAT names, MBR partitions; writes FAT12 floppies |
|
||||
| Unity package (`.unitypackage`) | yes | yes | assets by path, `.meta` files beside them, guids, previews; needs the extension to beat gzip |
|
||||
| Cabinet (`.cab`) | yes | yes | stored / MSZIP / LZX / Quantum (read), stored / MSZIP (write); no spanned files |
|
||||
|
||||
Full capability list: [FORMATS.md](../FORMATS.md).
|
||||
|
||||
@@ -326,6 +326,29 @@ local bin = assert(F.save(acf, nil, { format = "vdf", binary = true }))
|
||||
assert(F.data.load(bin, { format = "vdf" }).AppState.appid == "440")
|
||||
```
|
||||
|
||||
## Godot resources (.tres)
|
||||
|
||||
Godot text resources load as a table: `type` (the resource class), `format`, `uid`, `scriptClass`, `external` (the
|
||||
`ext_resource` list: `id`, `type`, `path`, `uid`), `subresources` (`id`, `type`, `properties`) and `properties` (the
|
||||
`[resource]` section, in file order). Godot values that Luau lacks are `{ type, args }` tables: `Vector3(1, 2, 3)` is
|
||||
`{ type = "Vector3", args = { 1, 2, 3 } }`, likewise `Color`, `Transform3D`, `PackedFloat32Array`, `NodePath`,
|
||||
`&"StringName"` (`type = "StringName"`), `SubResource("id")` and `ExtResource("id")`; `Object(Class, ...)` has `class`
|
||||
and its properties in `args[1]`. Godot dictionaries keep their order and may have number keys. Godot tells integers
|
||||
from floats, so integral floats read from a file (`1.0`) are written back as floats.
|
||||
`F.format("tres")` and the codec `F._internal("codecs/text/GodotVariant")` (`value`, `format`, `isCtor`, `ctor`)
|
||||
help with the values. Scenes (`.tscn`) are models: see [the scene guide](scene.md).
|
||||
|
||||
```luau
|
||||
local res = assert(F.data.load(tresText))
|
||||
assert(res.type == "StandardMaterial3D" and res.external[1].path == "res://brick.png")
|
||||
local c = res.properties.albedo_color
|
||||
assert(c.type == "Color" and c.args[1] == 0.8)
|
||||
assert(res.properties.albedo_texture.type == "ExtResource")
|
||||
res.properties.metallic = 0.5
|
||||
local text = assert(F.saveString(res, { format = "tres" }))
|
||||
assert(string.find(text, "metallic = 0.5", 1, true) and string.find(text, "roughness = 1.0", 1, true))
|
||||
```
|
||||
|
||||
## Quake III shaders and skins
|
||||
|
||||
Quake III `.shader` scripts load as a list of shaders: `{ name, directives, stages }`, each directive its tokens
|
||||
@@ -381,6 +404,7 @@ is an error there), CSV needs rows, INI needs sections of scalars, JSON has no b
|
||||
| cbor (`.cbor`) | yes | yes | values, buffers, Dates, tagged values |
|
||||
| plist (`.plist`) | XML + binary | XML | values, buffers, Dates |
|
||||
| nbt (`.nbt`, `.dat`, `.mcstructure`), snbt (`.snbt`) | yes | yes | typed values: see [Minecraft and voxels](voxel.md) |
|
||||
| tres (`.tres`) | yes | yes | Godot resources: sections, Variant values as `{ type, args }` |
|
||||
|
||||
Full capability list: [FORMATS.md](../FORMATS.md).
|
||||
|
||||
|
||||
@@ -991,6 +991,96 @@ local bones = arm:list("bonebase")
|
||||
assert(bones[1]:str("name") == "lower" and bones[1]:list("childbase")[1]:str("name") == "upper")
|
||||
```
|
||||
|
||||
## 3ds Max ASCII export (ASE)
|
||||
|
||||
`.ase` files (`*3DSMAX_ASCIIEXPORT`) load as a Z-up scene: one node per geometry, helper, camera and light object,
|
||||
parented by `*NODE_PARENT`. ASE stores mesh vertices in world space; the reader moves them into the node's frame (the
|
||||
inverse `*NODE_TM`), so `Scene.flatten` puts them back where 3ds Max had them. Faces split into one primitive per
|
||||
sub-material of a Multi/Sub-Object material (`*MESH_MTLID`); each corner is its own vertex (texture channels,
|
||||
vertex colours and `*MESH_VERTEXNORMAL`s are per corner). Materials are Phong (the raw values in `extras`), bitmaps
|
||||
become textures with a `uri` (data through `opts.resolve`), UVW tiling / offset a texture transform. Camera FOVs
|
||||
stay the stored horizontal angle. `*TM_ANIMATION` tracks are not read (`meta.source.animated` says they exist).
|
||||
The writer puts every scene material in one Multi/Sub-Object material and writes world-space vertices.
|
||||
|
||||
```luau
|
||||
local scene = assert(F.load(aseText))
|
||||
assert(scene.meta.source.format == "ase" and scene.meta.up == "z")
|
||||
assert(#scene.materials == 2 and scene.materials[1].name == "Brick")
|
||||
local quad = scene.nodes[2]
|
||||
assert(quad.name == "Quad" and #scene.meshes[quad.mesh].primitives == 2)
|
||||
local tex = scene.textures[scene.materials[1].baseColorTexture.texture]
|
||||
assert(tex.uri == "textures\\brick.png")
|
||||
local again = assert(F.load(F.save(scene, nil, { format = "ase" })))
|
||||
assert(#again.meshes[again.nodes[2].mesh].primitives == 2)
|
||||
```
|
||||
|
||||
## Godot scenes (TSCN / ESCN)
|
||||
|
||||
Godot text scenes load as a Y-up Scene (one node per `[node]`, the scene root first), checked against Godot 4's own
|
||||
loader. Node3D transforms come from `transform = Transform3D(...)` (or `position` / `rotation` / `scale`); a
|
||||
MeshInstance3D gets its ArrayMesh sub-resource (Godot 4.2+ surfaces, and the `"arrays"` surfaces of Godot 3 / Blender
|
||||
`.escn` files) or its primitive mesh (Box, Plane, Quad, Sphere and Cylinder are built as Godot builds them), with
|
||||
`surface_material_override/N` applied. StandardMaterial3D / SpatialMaterial become PBR materials (Godot's sRGB
|
||||
albedo and emission converted to linear; the raw values in `material.extras.godot`); textures are `ExtResource`
|
||||
paths (`res://` dropped) with their bytes through `opts.resolve`. Camera3D (`fov` is vertical) and Omni / Spot /
|
||||
Directional lights map to cameras and lights (`intensity` = `light_energy`). Instanced scenes
|
||||
(`instance=ExtResource(...)`) are read through `opts.resolve` and grafted under their node. Godot's front faces are
|
||||
clockwise: indices are reversed into glTF's counter-clockwise winding (and back on save). Every node keeps its Godot
|
||||
type and raw properties in `node.extras.godot`, so 2D trees (Node2D, Sprite2D, Control) are kept there too.
|
||||
|
||||
```luau
|
||||
local scene = assert(F.load(tscnText, { resolve = function(path) return nil end }))
|
||||
assert(scene.meta.source.format == "godot" and scene.meta.up == "y")
|
||||
local box = scene.nodes[2]
|
||||
assert(box.name == "Box" and box.extras.godot.type == "MeshInstance3D")
|
||||
assert(box.matrix[13] == 2) -- Transform3D origin x
|
||||
local mat = scene.materials[scene.meshes[box.mesh].primitives[1].material]
|
||||
assert(mat.extras.godot.albedo[1] == 1 and mat.metallic == 0.5)
|
||||
assert(scene.cameras[1].type == "perspective" and math.abs(math.deg(scene.cameras[1].yfov) - 60) < 1e-9)
|
||||
local hud = scene.nodes[4]
|
||||
assert(hud.extras.godot.type == "Node2D" and hud.extras.godot.properties.position.args[1] == 10)
|
||||
local tscn = assert(F.saveString(scene, { format = "godot" })) -- Godot 4 text, format 3
|
||||
assert(string.find(tscn, '[node name="Box" type="MeshInstance3D" parent="."]', 1, true))
|
||||
```
|
||||
|
||||
The writer makes Node3D / MeshInstance3D / Camera3D / light nodes, ArrayMesh sub-resources (uncompressed format 2
|
||||
surfaces with positions, normals, tangents, colours, two UV sets) and StandardMaterial3D, plus a `Texture2D`
|
||||
`ext_resource` per texture with a `uri`. Skins, animations and morph targets are not written. Godot resources
|
||||
(`.tres`) are data: see [data.md](data.md).
|
||||
|
||||
## Unreal T3D
|
||||
|
||||
UnrealEd's text export (`.t3d`: `Begin Map` / `Begin Actor` / `Begin Brush` / `Begin PolyList` / `Begin Polygon`,
|
||||
UE1 to UE4) loads as a Scene in Unreal's own Z-up, left-handed coordinates (`meta.handedness = "left"`; nothing is
|
||||
mirrored). Every actor is a root node with its class, properties, CSG operation and components in
|
||||
`node.extras.t3d`; its matrix is the brush transform (PrePivot, MainScale, Rotation, PostScale, Location; rotations
|
||||
in 65536ths of a turn, or degrees in UE4 text) or the actor's Location / Rotation / DrawScale (UE4: the root
|
||||
component's `Relative*`). Brush polygons become one primitive per texture through `codecs/model/Brush`, with UVs from
|
||||
`TextureU` / `TextureV` / `Origin` / `Pan` divided by the texture size (`opts.textureSize`: a function or a
|
||||
`{ [name] = { w, h } }` table, default 256). Triangles wind counter-clockwise about each polygon's stored normal;
|
||||
subtractive brushes are turned inside out (a room is seen from within), the red builder brush is skipped unless
|
||||
`builder = true`. No BSP CSG is done: overlapping brushes stay separate meshes. Lights (UE1 hue / saturation /
|
||||
brightness, UE3-4 light components) and cameras map across; static mesh actors keep their mesh path in
|
||||
`extras.t3d.staticMesh`.
|
||||
|
||||
```luau
|
||||
local level = assert(F.load(t3dText, { textureSize = { Bricks = { 128, 64 }, Floor = { 256, 256 } } }))
|
||||
assert(level.meta.source.format == "t3d" and level.meta.up == "z")
|
||||
local room
|
||||
for _, n in level.nodes do
|
||||
if n.name == "Brush0" then
|
||||
room = n
|
||||
end
|
||||
end
|
||||
assert(room.extras.t3d.csg == "CSG_Subtract" and room.mesh)
|
||||
assert(room.matrix[13] == 64) -- Location X
|
||||
local names = {}
|
||||
for _, p in level.meshes[room.mesh].primitives do
|
||||
names[level.materials[p.material].name] = true
|
||||
end
|
||||
assert(names.Bricks and names.Floor)
|
||||
```
|
||||
|
||||
## Formats
|
||||
|
||||
| Format | Read | Write | Notes |
|
||||
@@ -1031,6 +1121,9 @@ assert(bones[1]:str("name") == "lower" and bones[1]:list("childbase")[1]:str("na
|
||||
| Doom 3 / Quake 4 `.map` (d3map) | yes | | brushDef3, patchDef2 / 3, entities as nodes |
|
||||
| UDMF (`.udmf`, `TEXTMAP`) | yes | | Doom maps as text: see "Doom maps (UDMF)" above |
|
||||
| Blender `.blend` | yes | | 2.4x - 5.x, compressed; meshes of every generation, materials, skins, shape keys, actions; see "Blender" above |
|
||||
| Unreal T3D (`.t3d`) | yes | - | brushes as polygons per texture (no CSG), actors with properties, lights, cameras; Z up, left-handed |
|
||||
| Godot `.tscn` / `.escn` | yes | yes (`.tscn`) | Node3D trees, ArrayMesh and primitive meshes, StandardMaterial3D, cameras, lights, instances; 2D nodes in extras |
|
||||
| ASE (3ds Max ASCII) | yes | yes | Multi/Sub-Object materials, texture channels, vertex colours, normals, helpers, cameras, lights; no animation; Z up |
|
||||
| Roblox `.mesh` (robloxmesh) | yes | yes | see [roblox.md](roblox.md) |
|
||||
| Roblox `.rbxm` / `.rbxl`, `.rbxmx` / `.rbxlx` | as an `RbxTree` | yes | instance trees with typed properties: see [roblox.md](roblox.md) |
|
||||
|
||||
|
||||
+82
-1
@@ -1,4 +1,4 @@
|
||||
# Tile maps (Tiled TMX / TMJ)
|
||||
# Tile maps (Tiled, LDtk, Ogmo)
|
||||
|
||||
[Tiled](https://www.mapeditor.org) maps load as a `TileMap`: the map grid, its tilesets, and a list of layers
|
||||
(tile layers, object layers, image layers and groups) with Tiled's custom properties. The XML flavour (TMX) and the
|
||||
@@ -212,6 +212,83 @@ local maps = assert(F.format("gamemaps").maps(F.Bytes.reader(mapheadBytes), { ga
|
||||
assert(#maps == 1 and maps[1].slot == 1)
|
||||
```
|
||||
|
||||
## LDtk
|
||||
|
||||
[LDtk](https://ldtk.io) projects (`.ldtk`) load as a `TileMap` whose top layers are the **levels**: one `"group"`
|
||||
layer per level (`level = true`, `offsetX` / `offsetY` = its world position in pixels, `pxWidth` / `pxHeight`, the
|
||||
level fields as `properties`), holding the level's layers bottom first. Multi-world projects add one group per
|
||||
world (`world = true`) around its levels. External levels (`.ldtkl`) load through `opts.resolve(relPath)`; without
|
||||
it the level group has `unresolved = true` and no layers.
|
||||
|
||||
| LDtk layer | `TileLayer` |
|
||||
|---|---|
|
||||
| Tiles, AutoLayer | `type = "tiles"`, `tiles` (every tile: `x`, `y` pixels, `tile` id, `flip` bits, `srcX` / `srcY`, `alpha`), `data` (a gid grid of the top tile per cell), `tileset` |
|
||||
| IntGrid | the same plus `intGrid` (one value per cell, 0 = empty) and `intGridValues` (`{ value, identifier, color }`) |
|
||||
| Entities | `type = "objects"`: `class` = the entity identifier, `x` / `y` top-left (pixel position minus `pivot` x size), `width`, `height`, `pivot`, `tags`, `tile`, the fields as `properties` / `propertyTypes` (LDtk type names) |
|
||||
|
||||
Every layer also has `ldtkType` and `gridSize` (LDtk layers have their own cell size), and the raw LDtk tables
|
||||
(definitions, iids, uids, rules) ride along in `.ldtk` fields so a save keeps them. Gids are the tileset's
|
||||
`firstGid` plus the LDtk tile id, with LDtk's X / Y flips as Tiled's flip bits.
|
||||
|
||||
```luau
|
||||
local map = assert(F.load(ldtkText))
|
||||
assert(map.meta.source.format == "ldtk")
|
||||
local level = map.layers[1]
|
||||
assert(level.level and level.name == "Stamps" and level.pxWidth == 272)
|
||||
local walls = level.layers[1]
|
||||
assert(walls.ldtkType == "IntGrid" and walls.intGridValues[1].identifier == "walls")
|
||||
assert(#walls.tiles == 118 and map.tilesets[1].imageSource == "atlas/Inca_front_by_Kronbits-extended.png")
|
||||
local cx, cy = walls.tiles[1].x // walls.gridSize, walls.tiles[1].y // walls.gridSize
|
||||
assert(walls.data[1 + cx + cy * walls.width] ~= 0)
|
||||
```
|
||||
|
||||
Saving writes an LDtk project: maps read from LDtk keep their definitions and raw fields (changed `properties` get
|
||||
new `realEditorValues`, so the editor sees them); other maps (a Tiled map, a new `TileMap`) get layer, tileset and
|
||||
entity definitions made from their content, their loose layers forming one level. A tile layer writes its `tiles`
|
||||
list when it has one, else its `data` grid; set `tiles = nil` after editing `data`. Levels are always embedded.
|
||||
|
||||
```luau
|
||||
local map = F.Types.TileMap.new(2, 1, 16, 16)
|
||||
table.insert(map.tilesets, { name = "t", firstGid = 1, tileWidth = 16, tileHeight = 16, columns = 2, count = 4,
|
||||
imageSource = "t.png", imageWidth = 32, imageHeight = 32 })
|
||||
table.insert(map.layers, { type = "tiles", name = "Floor", width = 2, height = 1, visible = true, opacity = 1,
|
||||
properties = {}, data = { 1, 4 } })
|
||||
local ldtk = assert(F.save(map, nil, { format = "ldtk" }))
|
||||
local back = assert(F.load(ldtk))
|
||||
assert(back.layers[1].layers[1].tiles[2].tile == 3)
|
||||
```
|
||||
|
||||
## Ogmo Editor 3
|
||||
|
||||
[Ogmo Editor 3](https://ogmo-editor-3.github.io) keeps a project (`.ogmo`: layer definitions, entity templates,
|
||||
tilesets with their images embedded) and one JSON file per level. A level loads as a `TileMap`; pass its project as
|
||||
`opts.project` (bytes or decoded JSON) to get the tilesets (gids), the map grid, entity template sizes and value
|
||||
types. Without it tile layers keep `id + 1` as their gids. A project alone loads with `meta.project = true`, its
|
||||
tilesets and one empty layer per definition.
|
||||
|
||||
| Ogmo layer | `TileLayer` (`ogmoType`) |
|
||||
|---|---|
|
||||
| tile (ids or coords, 1D or 2D) | `"tiles"` (`"tile"`): `data` gids, `tileset`, the tile flags as Tiled flip bits |
|
||||
| grid | `"tiles"` (`"grid"`): `grid` (the cell strings, `"0"` empty), `data` (their numbers), `legend` |
|
||||
| entity | `"objects"` (`"entity"`): `x` / `y` top-left (position minus `originX` / `originY`), `width`, `height`, `rotation` in degrees, `flippedX` / `flippedY`, `nodes` (`{ { x, y } }`), values as `properties` |
|
||||
| decal | `"objects"` (`"decal"`): `texture`, `x` / `y`, `scaleX` / `scaleY`, `rotation` in degrees, `originX` / `originY` |
|
||||
|
||||
Ogmo's first layer is drawn on top, so the layers are reversed (bottom first, as everywhere in `TileMap`). Layers keep
|
||||
their cell size (`cellWidth`, `cellHeight`) and save layout (`exportMode`, `arrayMode`). Tileset images stay bytes
|
||||
(`tileset.imageData`, a PNG) next to their `imageSource` path.
|
||||
|
||||
```luau
|
||||
local map = assert(F.load(ogmoLevelText, { format = "ogmo", project = ogmoProjectText }))
|
||||
assert(map.pxWidth == 640 and map.tileWidth == 8) -- the project's grid
|
||||
local walls = map.layers[1]
|
||||
assert(walls.ogmoType == "tile" and walls.tileset == "tiles" and walls.width == 40)
|
||||
local things = map.layers[2]
|
||||
assert(things.objects[1].class == "player" and things.objects[1].x == 128)
|
||||
local level = assert(F.save(map, nil, { format = "ogmo" })) -- a level
|
||||
local project = assert(F.save(map, nil, { format = "ogmo", kind = "project" })) -- a project for any map
|
||||
assert(F.detect(project) == "ogmo")
|
||||
```
|
||||
|
||||
## Formats
|
||||
|
||||
| Format | Read | Write | Notes |
|
||||
@@ -221,6 +298,10 @@ assert(#maps == 1 and maps[1].slot == 1)
|
||||
| Wolfenstein 3D GAMEMAPS + MAPHEAD | yes | | the `gamemaps` format: raw tile values, no tileset |
|
||||
|
||||
TMX and TMJ are the `tiled` format in [FORMATS.md](../FORMATS.md). Wang sets and terrains are dropped.
|
||||
| LDtk (`.ldtk`) | yes | yes | levels as groups, worlds, IntGrid / auto / tile / entity layers, fields; `.ldtkl` through `resolve`; writes embedded levels |
|
||||
| Ogmo Editor 3 (`.ogmo`, level `.json`) | yes | yes | tile / grid / entity / decal layers, values; the project through `opts.project` |
|
||||
|
||||
TMX and TMJ are both the `tiled` format in [FORMATS.md](../FORMATS.md) (Wang sets and terrains are dropped).
|
||||
|
||||
## Gotchas
|
||||
|
||||
|
||||
Reference in new issue
Block a user