Update capture script

- Make it possible to free roam before capturing
- Show coordinates (Also while capturing)
- Disable grid updates and some other magic number adjustments
This commit is contained in:
David Vogel 2019-10-25 17:29:52 +02:00
parent 91efa7b4ba
commit b923ee6f51
4 changed files with 54 additions and 28 deletions

View File

@ -26,7 +26,8 @@ local function resetPlayer()
end end
function startCapturing() function startCapturing()
local ox, oy = getPlayerPos() local ox, oy = GameGetCameraPos()
--getPlayerPos()
ox, oy = math.floor(ox / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE, math.floor(oy / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE ox, oy = math.floor(ox / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE, math.floor(oy / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE
local x, y = ox, oy local x, y = ox, oy
@ -43,8 +44,11 @@ function startCapturing()
local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE
if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then
GameSetCameraPos(x, y) GameSetCameraPos(x, y)
wait(CAPTURE_DELAY) wait(CAPTURE_DELAY - 1)
UiHide = true -- Hide UI while capturing the screenshot
wait(1)
TriggerCapture(rx, ry) TriggerCapture(rx, ry)
UiHide = false
end end
x, y = x + CAPTURE_GRID_SIZE, y x, y = x + CAPTURE_GRID_SIZE, y
end end
@ -53,8 +57,11 @@ function startCapturing()
local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE
if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then
GameSetCameraPos(x, y) GameSetCameraPos(x, y)
wait(CAPTURE_DELAY) wait(CAPTURE_DELAY - 1)
UiHide = true
wait(1)
TriggerCapture(rx, ry) TriggerCapture(rx, ry)
UiHide = false
end end
x, y = x, y + CAPTURE_GRID_SIZE x, y = x, y + CAPTURE_GRID_SIZE
end end
@ -64,8 +71,11 @@ function startCapturing()
local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE
if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then
GameSetCameraPos(x, y) GameSetCameraPos(x, y)
wait(CAPTURE_DELAY) wait(CAPTURE_DELAY - 1)
UiHide = true
wait(1)
TriggerCapture(rx, ry) TriggerCapture(rx, ry)
UiHide = false
end end
x, y = x - CAPTURE_GRID_SIZE, y x, y = x - CAPTURE_GRID_SIZE, y
end end
@ -74,8 +84,11 @@ function startCapturing()
local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE local rx, ry = x * CAPTURE_PIXEL_SIZE, y * CAPTURE_PIXEL_SIZE
if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then if not fileExists(string.format("mods/noita-mapcap/output/%d,%d.png", rx, ry)) then
GameSetCameraPos(x, y) GameSetCameraPos(x, y)
wait(CAPTURE_DELAY) wait(CAPTURE_DELAY - 1)
UiHide = true
wait(1)
TriggerCapture(rx, ry) TriggerCapture(rx, ry)
UiHide = false
end end
x, y = x, y - CAPTURE_GRID_SIZE x, y = x, y - CAPTURE_GRID_SIZE
end end

View File

@ -3,5 +3,10 @@
CAMERA_NO_MOVE_BUFFER_NEAR_VIEWPORT_EDGE="0.0" CAMERA_NO_MOVE_BUFFER_NEAR_VIEWPORT_EDGE="0.0"
CAMERA_MOUSE_INTERPOLATION_SPEED="0.0" CAMERA_MOUSE_INTERPOLATION_SPEED="0.0"
CAMERA_POSITION_INTERPOLATION_SPEED="50.0" CAMERA_POSITION_INTERPOLATION_SPEED="50.0"
DRAW_PARALLAX_BACKGROUND="0"> DRAW_PARALLAX_BACKGROUND="0"
DEBUG_FREE_CAMERA_SPEED="10"
DEBUG_NO_LOGO_SPLASHES="1"
DEBUG_PAUSE_GRID_UPDATE="1"
DEBUG_PAUSE_BOX2D="1"
DEBUG_DISABLE_POSTFX_DITHERING="1">
</MagicNumbers> </MagicNumbers>

View File

@ -3,31 +3,41 @@
-- 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
UiHide = false
local UiReduce = false
async_loop( async_loop(
function() function()
if modGUI ~= nil then if modGUI ~= nil then
GuiStartFrame(modGUI) GuiStartFrame(modGUI)
GuiLayoutBeginVertical(modGUI, 50, 20) GuiLayoutBeginVertical(modGUI, 50, 50)
if GuiButton(modGUI, 0, 0, "Start capturing map", 1) then if not UiReduce then
startCapturing() GuiTextCentered(modGUI, 0, 0, "You can freely look around and search a place to start capturing.")
GuiDestroy(modGUI) GuiTextCentered(modGUI, 0, 0, "The mod will then take images in a spiral around your current view.")
modGUI = nil GuiTextCentered(modGUI, 0, 0, "Use ESC and close the game to stop the process.")
GuiTextCentered(
modGUI,
0,
0,
'You can resume capturing just by restarting noita and pressing "Start capturing map" again,'
)
GuiTextCentered(modGUI, 0, 0, "the mod will skip already captured files.")
GuiTextCentered(
modGUI,
0,
0,
'If you want to start a new map, you have to delete all images from the "output" folder!'
)
if GuiButton(modGUI, 0, 0, ">> Start capturing map <<", 1) then
startCapturing()
UiReduce = true
end
end
if not UiHide then
local x, y = GameGetCameraPos()
GuiTextCentered(modGUI, 0, 0, string.format("Coordinates: %d, %d", x, y))
end end
GuiTextCentered(modGUI, 0, 0, "Use ESC and close the game to stop the process.")
GuiTextCentered(
modGUI,
0,
0,
'You can resume capturing just by restarting noita and pressing "Start capturing map" again,'
)
GuiTextCentered(modGUI, 0, 0, "the mod will skip already captured files.")
GuiTextCentered(
modGUI,
0,
0,
'If you want to start a new map, you have to delete all images from the "output" folder!'
)
GuiLayoutEnd(modGUI) GuiLayoutEnd(modGUI)
end end

View File

@ -3,6 +3,7 @@ dofile("mods/noita-mapcap/files/init.lua")
function OnPlayerSpawned(player_entity) function OnPlayerSpawned(player_entity)
--EntityLoad("mods/noita-mapcap/files/luacomponent.xml") -- ffi isn't accessible from inside lua components, scrap that idea --EntityLoad("mods/noita-mapcap/files/luacomponent.xml") -- ffi isn't accessible from inside lua components, scrap that idea
modGUI = GuiCreate() modGUI = GuiCreate()
GameSetCameraFree(true)
end end
function OnWorldPostUpdate() -- this is called every time the game has finished updating the world function OnWorldPostUpdate() -- this is called every time the game has finished updating the world
@ -10,6 +11,3 @@ function OnWorldPostUpdate() -- this is called every time the game has finished
end end
ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic_numbers.xml") -- override some game constants ModMagicNumbersFileAdd("mods/noita-mapcap/files/magic_numbers.xml") -- override some game constants
-- Only works up to the 16-10-2019 version of noita. And even then, ffi and other nice stuff is only accessible here.
--ModLuaFileAppend("data/scripts/director_init.lua", "mods/noita-mapcap/files/init.lua")