mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
Make it possible to resume the capture process
This commit is contained in:
parent
102f9f337c
commit
1a4700eba3
@ -3,8 +3,8 @@
|
||||
-- This software is released under the MIT License.
|
||||
-- https://opensource.org/licenses/MIT
|
||||
|
||||
local CAPTURE_PIXEL_SIZE = 2 -- in FullHD a ingame pixel is expected to be 2 real pixels
|
||||
local CAPTURE_GRID_SIZE = 1080 / 4 -- in ingame pixels
|
||||
local CAPTURE_PIXEL_SIZE = 2 -- in FullHD an ingame pixel is expected to be 2 real pixels
|
||||
local CAPTURE_GRID_SIZE = 256 -- in ingame pixels. There will be 6 to 12 images overlapping
|
||||
local CAPTURE_DELAY = 15 -- in frames
|
||||
local CAPTURE_FORCE_HP = 4 -- * 25HP
|
||||
|
||||
@ -40,32 +40,44 @@ function startCapturing()
|
||||
function()
|
||||
-- +x
|
||||
for i = 1, i, 1 do
|
||||
TriggerCapture(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
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
TriggerCapture(rx, ry)
|
||||
end
|
||||
x, y = x + CAPTURE_GRID_SIZE, y
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
end
|
||||
-- +y
|
||||
for i = 1, i, 1 do
|
||||
TriggerCapture(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
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
TriggerCapture(rx, ry)
|
||||
end
|
||||
x, y = x, y + CAPTURE_GRID_SIZE
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
end
|
||||
i = i + 1
|
||||
-- -x
|
||||
for i = 1, i, 1 do
|
||||
TriggerCapture(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
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
TriggerCapture(rx, ry)
|
||||
end
|
||||
x, y = x - CAPTURE_GRID_SIZE, y
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
end
|
||||
-- -y
|
||||
for i = 1, i, 1 do
|
||||
TriggerCapture(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
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
TriggerCapture(rx, ry)
|
||||
end
|
||||
x, y = x, y - CAPTURE_GRID_SIZE
|
||||
GameSetCameraPos(x, y)
|
||||
wait(CAPTURE_DELAY)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
|
21
files/ui.lua
21
files/ui.lua
@ -14,15 +14,20 @@ async_loop(
|
||||
GuiDestroy(modGUI)
|
||||
modGUI = nil
|
||||
end
|
||||
GuiTextCentered(modGUI, 0, 0, "Don't do anything while the capturing process is running!")
|
||||
GuiTextCentered(modGUI, 0, 0, "Use ESC and close the game to stop the process.")
|
||||
--[[if GuiButton(gui, 0, 0, "DEBUG globals", 1) then
|
||||
local file = io.open("mods/noita-mapcap/output/globals.txt", "w")
|
||||
for i, v in pairs(_G) do
|
||||
file:write(i .. "\n")
|
||||
end
|
||||
file:close()
|
||||
end]]
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -87,3 +87,13 @@ function addPerkToPlayer(perkID)
|
||||
--local effect = EntityLoad("data/entities/misc/effect_protection_all.xml", x, y)
|
||||
--EntityAddChild(playerEntity, effect)
|
||||
end
|
||||
|
||||
function fileExists(fileName)
|
||||
local f = io.open(fileName, "r")
|
||||
if f ~= nil then
|
||||
io.close(f)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user