Skip to content

Commit

Permalink
Update capture process
Browse files Browse the repository at this point in the history
- When being in `CaptureDelay` mode, just shake viewport a little bit
- When DoesWorldExistAt still does return false after 600 frames, move viewport to somewhere else, and try again.
  • Loading branch information
Dadido3 committed Feb 8, 2024
1 parent 9cfb011 commit b4dca53
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion files/capture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
if ctx then ctx.state.WaitFrames = 0 end

-- Wait some additional frames.
-- We will shake the screen a little bit so that Noita generates/populates chunks.
if captureDelay and captureDelay > 0 then
for _ = 1, captureDelay do
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-10, 10), math.random(-10, 10))) end
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-1, 1), math.random(-1, 1))) end
wait(0)
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 1 end
end
Expand All @@ -109,6 +110,18 @@ local function captureScreenshot(pos, ensureLoaded, dontOverwrite, ctx, outputPi
if pos then CameraAPI.SetPos(pos) end
end

if delayFrames > 600 then
-- Shaking wasn't enough, we will just move somewhere else an try again.
if pos then CameraAPI.SetPos(pos + Vec2(math.random(-4000, 4000), math.random(-4000, 4000))) end
wait(50)
delayFrames = delayFrames + 50
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 50 end
if pos then CameraAPI.SetPos(pos) end
wait(10)
delayFrames = delayFrames + 10
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 10 end
end

wait(0)
delayFrames = delayFrames + 1
if ctx then ctx.state.WaitFrames = ctx.state.WaitFrames + 1 end
Expand Down

0 comments on commit b4dca53

Please sign in to comment.