This commit is contained in:
David Vogel 2022-07-23 10:57:25 +02:00
parent 2acc4e7e93
commit 508771c347
3 changed files with 7 additions and 7 deletions

View File

@ -10,7 +10,7 @@ local EntityAPI = dofile_once("mods/noita-mapcap/files/libraries/noita-api/entit
local Hilbert = dofile_once("mods/noita-mapcap/files/libraries/hilbert-curve.lua") local Hilbert = dofile_once("mods/noita-mapcap/files/libraries/hilbert-curve.lua")
---@type JSONLib ---@type JSONLib
local json = dofile_once("mods/noita-mapcap/files/libraries/json.lua") local JSON = dofile_once("mods/noita-mapcap/files/libraries/json.lua")
CAPTURE_PIXEL_SIZE = 1 -- Screen to virtual pixel ratio. CAPTURE_PIXEL_SIZE = 1 -- Screen to virtual pixel ratio.
CAPTURE_GRID_SIZE = 512 -- in virtual (world) pixels. There will always be exactly 4 images overlapping if the virtual resolution is 1024x1024. CAPTURE_GRID_SIZE = 512 -- in virtual (world) pixels. There will always be exactly 4 images overlapping if the virtual resolution is 1024x1024.
@ -93,11 +93,11 @@ local function captureEntities(entityFile, x, y, radius)
-- Well, as long as it does not crash between write and flush. -- Well, as long as it does not crash between write and flush.
if entityFile:seek("end") == 0 then if entityFile:seek("end") == 0 then
-- First line. -- First line.
entityFile:write("[\n\t", json.Marshal(rootEntity), "\n", "]") entityFile:write("[\n\t", JSON.Marshal(rootEntity), "\n", "]")
else else
-- Following lines. -- Following lines.
entityFile:seek("end", -2) -- Seek a few bytes back, so we can overwrite some stuff. entityFile:seek("end", -2) -- Seek a few bytes back, so we can overwrite some stuff.
entityFile:write(",\n\t", json.Marshal(rootEntity), "\n", "]") entityFile:write(",\n\t", JSON.Marshal(rootEntity), "\n", "]")
end end
-- Prevent recapturing. -- Prevent recapturing.

View File

@ -10,7 +10,7 @@
-- It would be optimal to generate this API wrapper automatically... -- It would be optimal to generate this API wrapper automatically...
---@type JSONLib ---@type JSONLib
local json = dofile_once("mods/noita-mapcap/files/libraries/json.lua") local JSON = dofile_once("mods/noita-mapcap/files/libraries/json.lua")
------------- -------------
-- Classes -- -- Classes --
@ -183,7 +183,7 @@ function NoitaComponent:MarshalJSON()
--objectMembers = component:ObjectGetMembers --objectMembers = component:ObjectGetMembers
} }
return json.Marshal(resultObject) return JSON.Marshal(resultObject)
end end
return ComponentAPI return ComponentAPI

View File

@ -16,7 +16,7 @@ local ComponentAPI = dofile_once("mods/noita-mapcap/files/libraries/noita-api/co
local Vec2 = dofile_once("mods/noita-mapcap/files/libraries/vec2.lua") local Vec2 = dofile_once("mods/noita-mapcap/files/libraries/vec2.lua")
---@type JSONLib ---@type JSONLib
local json = dofile_once("mods/noita-mapcap/files/libraries/json.lua") local JSON = dofile_once("mods/noita-mapcap/files/libraries/json.lua")
------------- -------------
-- Classes -- -- Classes --
@ -371,7 +371,7 @@ function NoitaEntity:MarshalJSON()
result.transform.x, result.transform.y, result.transform.rotation, result.transform.scaleX, result.transform.scaleY = self:GetTransform() result.transform.x, result.transform.y, result.transform.rotation, result.transform.scaleX, result.transform.scaleY = self:GetTransform()
return json.Marshal(result) return JSON.Marshal(result)
end end
return EntityAPI return EntityAPI