mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Set camera free based on mod settings
This commit is contained in:
parent
2cd9f1fc76
commit
f79d48fdc0
@ -154,7 +154,7 @@ function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale)
|
|||||||
---Process main callback.
|
---Process main callback.
|
||||||
---@param ctx ProcessRunnerCtx
|
---@param ctx ProcessRunnerCtx
|
||||||
local function handleDo(ctx)
|
local function handleDo(ctx)
|
||||||
CameraAPI.SetCameraFree(true)
|
Modification.SetCameraFree(true)
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
repeat
|
repeat
|
||||||
@ -183,8 +183,14 @@ function Capture:StartCapturingSpiral(origin, captureGridSize, outputPixelScale)
|
|||||||
until ctx:IsStopping()
|
until ctx:IsStopping()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Process end callback.
|
||||||
|
---@param ctx ProcessRunnerCtx
|
||||||
|
local function handleEnd(ctx)
|
||||||
|
Modification.SetCameraFree()
|
||||||
|
end
|
||||||
|
|
||||||
-- Run process, if there is no other running right now.
|
-- Run process, if there is no other running right now.
|
||||||
self.MapCapturingCtx:Run(nil, handleDo, nil, mapCapturingCtxErrHandler)
|
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Starts the capturing process of the given area.
|
---Starts the capturing process of the given area.
|
||||||
@ -222,7 +228,7 @@ function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outpu
|
|||||||
---Process main callback.
|
---Process main callback.
|
||||||
---@param ctx ProcessRunnerCtx
|
---@param ctx ProcessRunnerCtx
|
||||||
local function handleDo(ctx)
|
local function handleDo(ctx)
|
||||||
CameraAPI.SetCameraFree(true)
|
Modification.SetCameraFree(true)
|
||||||
ctx.progressCurrent, ctx.progressEnd = 0, gridSize.x * gridSize.y
|
ctx.progressCurrent, ctx.progressEnd = 0, gridSize.x * gridSize.y
|
||||||
|
|
||||||
while t < tLimit do
|
while t < tLimit do
|
||||||
@ -245,8 +251,14 @@ function Capture:StartCapturingArea(topLeft, bottomRight, captureGridSize, outpu
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Process end callback.
|
||||||
|
---@param ctx ProcessRunnerCtx
|
||||||
|
local function handleEnd(ctx)
|
||||||
|
Modification.SetCameraFree()
|
||||||
|
end
|
||||||
|
|
||||||
-- Run process, if there is no other running right now.
|
-- Run process, if there is no other running right now.
|
||||||
self.MapCapturingCtx:Run(nil, handleDo, nil, mapCapturingCtxErrHandler)
|
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Starts the live capturing process.
|
---Starts the live capturing process.
|
||||||
@ -267,6 +279,8 @@ function Capture:StartCapturingLive(interval, minDistance, maxDistance, outputPi
|
|||||||
---Process main callback.
|
---Process main callback.
|
||||||
---@param ctx ProcessRunnerCtx
|
---@param ctx ProcessRunnerCtx
|
||||||
local function handleDo(ctx)
|
local function handleDo(ctx)
|
||||||
|
Modification.SetCameraFree(false)
|
||||||
|
|
||||||
local oldPos
|
local oldPos
|
||||||
local minDistanceSqr, maxDistanceSqr = minDistance ^ 2, maxDistance ^ 2
|
local minDistanceSqr, maxDistanceSqr = minDistance ^ 2, maxDistance ^ 2
|
||||||
|
|
||||||
@ -286,8 +300,14 @@ function Capture:StartCapturingLive(interval, minDistance, maxDistance, outputPi
|
|||||||
until ctx:IsStopping()
|
until ctx:IsStopping()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Process end callback.
|
||||||
|
---@param ctx ProcessRunnerCtx
|
||||||
|
local function handleEnd(ctx)
|
||||||
|
Modification.SetCameraFree()
|
||||||
|
end
|
||||||
|
|
||||||
-- Run process, if there is no other running right now.
|
-- Run process, if there is no other running right now.
|
||||||
self.MapCapturingCtx:Run(nil, handleDo, nil, mapCapturingCtxErrHandler)
|
self.MapCapturingCtx:Run(nil, handleDo, handleEnd, mapCapturingCtxErrHandler)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Gathers all entities on the screen (around x, y within radius), serializes them, appends them into entityFile and modifies those entities.
|
---Gathers all entities on the screen (around x, y within radius), serializes them, appends them into entityFile and modifies those entities.
|
||||||
|
@ -10,10 +10,11 @@
|
|||||||
-- Load library modules --
|
-- Load library modules --
|
||||||
--------------------------
|
--------------------------
|
||||||
|
|
||||||
|
local CameraAPI = require("noita-api.camera")
|
||||||
|
local Coords = require("coordinates")
|
||||||
local NXML = require("luanxml.nxml")
|
local NXML = require("luanxml.nxml")
|
||||||
local Utils = require("noita-api.utils")
|
local Utils = require("noita-api.utils")
|
||||||
local Vec2 = require("noita-api.vec2")
|
local Vec2 = require("noita-api.vec2")
|
||||||
local Coords = require("coordinates")
|
|
||||||
|
|
||||||
----------
|
----------
|
||||||
-- Code --
|
-- Code --
|
||||||
@ -95,6 +96,23 @@ function Modification.RequiredChanges()
|
|||||||
return config, magic
|
return config, magic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Sets the camera free if required by the mod settings.
|
||||||
|
---@param force boolean|nil -- If true, the camera will be set free regardless.
|
||||||
|
function Modification.SetCameraFree(force)
|
||||||
|
if force ~= nil then CameraAPI.SetCameraFree(force) return end
|
||||||
|
|
||||||
|
local captureMode = ModSettingGet("noita-mapcap.capture-mode")
|
||||||
|
local spiralOrigin = ModSettingGet("noita-mapcap.capture-mode-spiral-origin")
|
||||||
|
|
||||||
|
-- Allow free roaming when in spiral mode with origin being the current position.
|
||||||
|
if captureMode == "spiral" and spiralOrigin == "current" then
|
||||||
|
CameraAPI.SetCameraFree(true)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
CameraAPI.SetCameraFree(false)
|
||||||
|
end
|
||||||
|
|
||||||
---Will change the game settings according to `Modification.RequiredChanges()`.
|
---Will change the game settings according to `Modification.RequiredChanges()`.
|
||||||
---
|
---
|
||||||
---This will force close Noita!
|
---This will force close Noita!
|
||||||
|
2
init.lua
2
init.lua
@ -91,6 +91,8 @@ end
|
|||||||
---Called once the game world is initialized.
|
---Called once the game world is initialized.
|
||||||
---Doesn't ensure any chunks around the player.
|
---Doesn't ensure any chunks around the player.
|
||||||
function OnWorldInitialized()
|
function OnWorldInitialized()
|
||||||
|
-- Set camera free based on mod settings.
|
||||||
|
Modification.SetCameraFree()
|
||||||
end
|
end
|
||||||
|
|
||||||
---Called *every* time the game is about to start updating the world.
|
---Called *every* time the game is about to start updating the world.
|
||||||
|
Loading…
Reference in New Issue
Block a user