vector/ogmo: Ogmo Editor 3 levels and projects read + write as a TileMap (tile / grid / entity / decal layers, every save layout, values; HaxeFlixel TurnBasedRPG sample, MIT)
This commit is contained in:
1 parent
1f74419ccf
commit
9c02ebdee5
15 files changed
+1596
-4
No files matched your search
@@ -0,0 +1,28 @@
|
||||
-- tools/fixtures/_ogmo_encode: run by tools/fixtures/ogmo.py (luau CLI, repo root): decodes every Ogmo level with its
|
||||
-- project and writes the level and a project made from the map with our encoder, printing "<name>.json\t<hex>" and
|
||||
-- "<name>.ogmo\t<hex>" lines for Python to read.
|
||||
local Ogmo = require("@rosetta/vector/ogmo")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
local Fx = require("@tests/gen/ogmo")
|
||||
|
||||
local HEX = {}
|
||||
for i = 0, 255 do
|
||||
HEX[i] = string.format("%02x", i)
|
||||
end
|
||||
local function hex(s: string): string
|
||||
return (string.gsub(s, ".", function(c: string): string
|
||||
return HEX[string.byte(c)]
|
||||
end))
|
||||
end
|
||||
|
||||
for _, c in Fx.cases do
|
||||
local map = Ogmo.decode(Bytes.reader(buffer.fromstring(c.data)), { project = c.project })
|
||||
if map then
|
||||
local lv = Ogmo.encode(map)
|
||||
local pj = Ogmo.encode(map, { kind = "project" })
|
||||
if lv and pj then
|
||||
print(c.name .. ".json\t" .. hex(buffer.tostring(lv)))
|
||||
print(c.name .. ".ogmo\t" .. hex(buffer.tostring(pj)))
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user