2022-07-18 20:53:34 +00:00
|
|
|
-- Copyright (c) 2022 David Vogel
|
2022-07-23 15:36:21 +00:00
|
|
|
--
|
2022-07-18 20:53:34 +00:00
|
|
|
-- This software is released under the MIT License.
|
|
|
|
-- https://opensource.org/licenses/MIT
|
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
-----------------------
|
|
|
|
-- Load global stuff --
|
|
|
|
-----------------------
|
2019-10-18 14:14:06 +00:00
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
-- 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 modFolder = "noita-mapcap"
|
|
|
|
dofile("mods/" .. modFolder .. "/files/libraries/noita-api/compatibility.lua")(modFolder)
|
2022-07-22 19:31:40 +00:00
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
if not async then
|
|
|
|
dofile_once("data/scripts/lib/coroutines.lua")
|
|
|
|
end
|
|
|
|
|
|
|
|
dofile("mods/noita-mapcap/files/external.lua")
|
|
|
|
dofile("mods/noita-mapcap/files/capture.lua")
|
|
|
|
dofile("mods/noita-mapcap/files/ui.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)
|
2019-10-22 20:48:43 +00:00
|
|
|
modGUI = GuiCreate()
|
2019-10-25 15:29:52 +00:00
|
|
|
GameSetCameraFree(true)
|
2022-07-19 16:28:30 +00:00
|
|
|
|
|
|
|
-- Start entity capturing right when the player spawn.
|
|
|
|
--DebugEntityCapture()
|
2019-10-18 14:14:06 +00:00
|
|
|
end
|
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
---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.
|
2022-07-19 16:28:30 +00:00
|
|
|
function OnWorldPreUpdate()
|
2022-07-23 15:36:21 +00:00
|
|
|
-- 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()
|
|
|
|
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()
|
2019-10-18 14:14:06 +00:00
|
|
|
end
|
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
---------------
|
|
|
|
-- Overrides --
|
|
|
|
---------------
|
2022-07-19 16:28:30 +00:00
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
-- Override virtual resolution and some other stuff.
|
|
|
|
ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic_numbers.xml")
|
2022-07-18 20:53:34 +00:00
|
|
|
|
2022-07-23 15:36:21 +00:00
|
|
|
-- Remove hover animation of newly created perks.
|
2022-07-19 16:28:30 +00:00
|
|
|
ModLuaFileAppend("data/scripts/perks/perk.lua", "mods/noita-mapcap/files/overrides/perks/perk.lua")
|