mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-10-16 08:17:32 +00:00
David Vogel
0126e706cb
- Add ability to capture while normally playing - Calculate capture area based on coordinate transformations - Improve and simplify captureScreenshot function - Move dynamic library wrappers into libraries folder - Update capture.dll to support cropping and resizing - Recompile capture.dll with newer PureBasic compiler that uses C backend - Increase capture.dll worker threads to 6 - Increase capture.dll queue size by one - Add Round and Rounded methods to Vec2 - Split magic number XML files for easier debugging - Fix some EmmyLua annotations - And and fix some comments
136 lines
3.9 KiB
Lua
136 lines
3.9 KiB
Lua
-- Copyright (c) 2022 David Vogel
|
|
--
|
|
-- This software is released under the MIT License.
|
|
-- https://opensource.org/licenses/MIT
|
|
|
|
-----------------------
|
|
-- Load global stuff --
|
|
-----------------------
|
|
|
|
-- Emulate and override some functions and tables to make everything conform more to standard lua.
|
|
-- This will make `require` work, even in sandboxes with restricted Noita API.
|
|
local libPath = "mods/noita-mapcap/files/libraries/"
|
|
dofile(libPath .. "noita-api/compatibility.lua")(libPath)
|
|
|
|
if not async then
|
|
require("coroutines") -- Loads Noita's coroutines library from `data/scripts/lib/coroutines.lua`.
|
|
end
|
|
|
|
--------------------------
|
|
-- Load library modules --
|
|
--------------------------
|
|
|
|
local Coords = require("coordinates")
|
|
local CameraAPI = require("noita-api.camera")
|
|
local DebugAPI = require("noita-api.debug")
|
|
local Vec2 = require("noita-api.vec2")
|
|
|
|
-------------------------------
|
|
-- Load and run script files --
|
|
-------------------------------
|
|
|
|
dofile("mods/noita-mapcap/files/capture.lua")
|
|
dofile("mods/noita-mapcap/files/ui.lua")
|
|
--dofile("mods/noita-mapcap/files/blablabla.lua")
|
|
|
|
--------------------
|
|
-- Hook callbacks --
|
|
--------------------
|
|
|
|
---Called in order upon loading a new(?) game.
|
|
function OnModPreInit()
|
|
end
|
|
|
|
---Called in order upon loading a new(?) game.
|
|
function OnModInit()
|
|
end
|
|
|
|
---Called in order upon loading a new(?) game.
|
|
function OnModPostInit()
|
|
end
|
|
|
|
---Called when player entity has been created.
|
|
---Ensures chunks around the player have been loaded & created.
|
|
---@param playerEntityID integer
|
|
function OnPlayerSpawned(playerEntityID)
|
|
modGUI = GuiCreate()
|
|
|
|
-- Start entity capturing right when the player spawn.
|
|
--DebugEntityCapture()
|
|
|
|
--[[async(function()
|
|
wait(0)
|
|
CameraAPI.SetCameraFree(true)
|
|
|
|
local origin = Vec2(512, -512)
|
|
CameraAPI.SetPos(origin)
|
|
|
|
DebugAPI.Mark(origin, "origin")
|
|
|
|
local tl, br = Coords:ValidRenderingRect()
|
|
local tlWorld, brWorld = Coords:ToWorld(tl), Coords:ToWorld(br)
|
|
DebugAPI.Mark(tlWorld, "tl")
|
|
DebugAPI.Mark(brWorld, "br")
|
|
end)]]
|
|
end
|
|
|
|
---Called when the player dies.
|
|
---@param playerEntityID integer
|
|
function OnPlayerDied(playerEntityID)
|
|
end
|
|
|
|
---Called once the game world is initialized.
|
|
---Doesn't ensure any chunks around the player.
|
|
function OnWorldInitialized()
|
|
end
|
|
|
|
---Called *every* time the game is about to start updating the world.
|
|
function OnWorldPreUpdate()
|
|
-- Coroutines aren't run every frame in this lua sandbox, do it manually here.
|
|
wake_up_waiting_threads(1)
|
|
end
|
|
|
|
---Called *every* time the game has finished updating the world.
|
|
function OnWorldPostUpdate()
|
|
end
|
|
|
|
---Called when the biome config is loaded.
|
|
function OnBiomeConfigLoaded()
|
|
end
|
|
|
|
---The last point where the Mod API is available.
|
|
---After this materials.xml will be loaded.
|
|
function OnMagicNumbersAndWorldSeedInitialized()
|
|
-- Get resolutions for correct coordinate transformations.
|
|
-- This needs to be done once all magic numbers are set.
|
|
Coords:ReadResolutions()
|
|
end
|
|
|
|
---Called when the game is paused or unpaused.
|
|
---@param isPaused boolean
|
|
---@param isInventoryPause boolean
|
|
function OnPausedChanged(isPaused, isInventoryPause)
|
|
end
|
|
|
|
---Will be called when the game is unpaused, if player changed any mod settings while the game was paused.
|
|
function OnModSettingsChanged()
|
|
end
|
|
|
|
---Will be called when the game is paused, either by the pause menu or some inventory menus.
|
|
---Please be careful with this, as not everything will behave well when called while the game is paused.
|
|
function OnPausePreUpdate()
|
|
end
|
|
|
|
---------------
|
|
-- Overrides --
|
|
---------------
|
|
|
|
-- Override virtual resolution and some other stuff.
|
|
--ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic-numbers/1024.xml")
|
|
ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic-numbers/fast-cam.xml")
|
|
--ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic-numbers/no-ui.xml")
|
|
ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic-numbers/offset.xml")
|
|
|
|
-- Remove hover animation of newly created perks.
|
|
ModLuaFileAppend("data/scripts/perks/perk.lua", "mods/noita-mapcap/files/overrides/perks/perk.lua")
|