mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Move coroutine wakeup back into OnWorldPreUpdate
This commit is contained in:
parent
d5cd88a30e
commit
44605b9633
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -13,6 +13,8 @@
|
|||||||
"downscaling",
|
"downscaling",
|
||||||
"DPMM",
|
"DPMM",
|
||||||
"executables",
|
"executables",
|
||||||
|
"framebuffer",
|
||||||
|
"framebuffers",
|
||||||
"Fullscreen",
|
"Fullscreen",
|
||||||
"goarch",
|
"goarch",
|
||||||
"gridify",
|
"gridify",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (c) 2019-2023 David Vogel
|
-- Copyright (c) 2019-2024 David Vogel
|
||||||
--
|
--
|
||||||
-- This software is released under the MIT License.
|
-- This software is released under the MIT License.
|
||||||
-- https://opensource.org/licenses/MIT
|
-- https://opensource.org/licenses/MIT
|
||||||
@ -108,9 +108,13 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
|
|||||||
-- Suspend UI drawing for 1 frame.
|
-- Suspend UI drawing for 1 frame.
|
||||||
UI:SuspendDrawing(1)
|
UI:SuspendDrawing(1)
|
||||||
|
|
||||||
--wait(0)
|
-- First we wait one frame for the current state to be drawn.
|
||||||
|
wait(0)
|
||||||
|
|
||||||
|
-- At this point the needed frame is fully drawn, but the framebuffers are swapped.
|
||||||
|
|
||||||
-- Recalculate capture position and rectangle if we are not forcing any capture position.
|
-- Recalculate capture position and rectangle if we are not forcing any capture position.
|
||||||
|
-- We are in the `OnWorldPreUpdate` hook, this means that `CameraAPI.GetPos` return the position of the last frame.
|
||||||
if not pos then
|
if not pos then
|
||||||
topLeftCapture, bottomRightCapture, topLeftWorld, bottomRightWorld = calculateCaptureRectangle(pos)
|
topLeftCapture, bottomRightCapture, topLeftWorld, bottomRightWorld = calculateCaptureRectangle(pos)
|
||||||
if outputPixelScale > 0 then
|
if outputPixelScale > 0 then
|
||||||
@ -120,8 +124,9 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Wait for two frames.
|
-- Wait another frame.
|
||||||
wait(1)
|
-- After this `wait` the framebuffer will be swapped again, and we can grab the correct frame.
|
||||||
|
wait(0)
|
||||||
|
|
||||||
-- The top left world position needs to be upscaled by the pixel scale.
|
-- The top left world position needs to be upscaled by the pixel scale.
|
||||||
-- Otherwise it's not possible to stitch the images correctly.
|
-- Otherwise it's not possible to stitch the images correctly.
|
||||||
|
10
init.lua
10
init.lua
@ -1,4 +1,4 @@
|
|||||||
-- Copyright (c) 2022 David Vogel
|
-- Copyright (c) 2022-2024 David Vogel
|
||||||
--
|
--
|
||||||
-- This software is released under the MIT License.
|
-- This software is released under the MIT License.
|
||||||
-- https://opensource.org/licenses/MIT
|
-- https://opensource.org/licenses/MIT
|
||||||
@ -109,19 +109,13 @@ end
|
|||||||
function OnWorldPreUpdate()
|
function OnWorldPreUpdate()
|
||||||
Message:CatchException("OnWorldPreUpdate", function()
|
Message:CatchException("OnWorldPreUpdate", function()
|
||||||
-- Coroutines aren't run every frame in this lua sandbox, do it manually here.
|
-- Coroutines aren't run every frame in this lua sandbox, do it manually here.
|
||||||
--wake_up_waiting_threads(1)
|
wake_up_waiting_threads(1)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Called *every* time the game has finished updating the world.
|
---Called *every* time the game has finished updating the world.
|
||||||
function OnWorldPostUpdate()
|
function OnWorldPostUpdate()
|
||||||
Message:CatchException("OnWorldPreUpdate", function()
|
|
||||||
-- Coroutines aren't run every frame in this lua sandbox, do it manually here.
|
|
||||||
wake_up_waiting_threads(1)
|
|
||||||
|
|
||||||
end)
|
|
||||||
|
|
||||||
Message:CatchException("OnWorldPostUpdate", function()
|
Message:CatchException("OnWorldPostUpdate", function()
|
||||||
-- Reload mod every 60 frames.
|
-- Reload mod every 60 frames.
|
||||||
-- This allows live updates to the mod while Noita is running.
|
-- This allows live updates to the mod while Noita is running.
|
||||||
|
Loading…
Reference in New Issue
Block a user