2019-10-18 20:35:51 +00:00
|
|
|
-- Copyright (c) 2019 David Vogel
|
|
|
|
--
|
|
|
|
-- This software is released under the MIT License.
|
|
|
|
-- https://opensource.org/licenses/MIT
|
|
|
|
|
2019-11-01 01:40:21 +00:00
|
|
|
CAPTURE_PIXEL_SIZE = 1 -- Screen to virtual pixel ratio
|
|
|
|
CAPTURE_GRID_SIZE = 420 -- in ingame pixels. There will always be 3 to 6 images overlapping
|
|
|
|
CAPTURE_DELAY = 15 -- in frames
|
|
|
|
CAPTURE_FORCE_HP = 4 -- * 25HP
|
2019-10-18 20:35:51 +00:00
|
|
|
|
|
|
|
local function preparePlayer()
|
|
|
|
local playerEntity = getPlayer()
|
|
|
|
addEffectToEntity(playerEntity, "PROTECTION_ALL")
|
|
|
|
|
|
|
|
addPerkToPlayer("BREATH_UNDERWATER")
|
|
|
|
addPerkToPlayer("INVISIBILITY")
|
|
|
|
addPerkToPlayer("REMOVE_FOG_OF_WAR")
|
|
|
|
addPerkToPlayer("REPELLING_CAPE")
|
|
|
|
addPerkToPlayer("WORM_DETRACTOR")
|
|
|
|
|
|
|
|
setPlayerHP(CAPTURE_FORCE_HP)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function resetPlayer()
|
|
|
|
setPlayerHP(CAPTURE_FORCE_HP)
|
|
|
|
end
|
|
|
|
|
2019-10-22 20:48:43 +00:00
|
|
|
function startCapturing()
|
2019-10-25 15:29:52 +00:00
|
|
|
local ox, oy = GameGetCameraPos()
|
|
|
|
--getPlayerPos()
|
2019-10-20 14:28:17 +00:00
|
|
|
ox, oy = math.floor(ox / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE, math.floor(oy / CAPTURE_GRID_SIZE) * CAPTURE_GRID_SIZE
|
2019-10-18 20:35:51 +00:00
|
|
|
local x, y = ox, oy
|
|
|
|
|
|
|
|
preparePlayer()
|
|
|
|
|
2019-10-20 14:28:17 +00:00
|
|
|
GameSetCameraFree(true)
|
2019-10-18 20:35:51 +00:00
|
|
|
|
|
|
|
-- Coroutine to calculate next coordinate, and trigger screenshots
|
|
|
|
local i = 1
|
|
|
|
async_loop(
|
|
|
|
function()
|
|
|
|
-- +x
|
|
|
|
for i = 1, i, 1 do
|
2019-10-23 18:03:03 +00:00
|
|
|
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)
|
2019-10-25 15:29:52 +00:00
|
|
|
wait(CAPTURE_DELAY - 1)
|
|
|
|
UiHide = true -- Hide UI while capturing the screenshot
|
|
|
|
wait(1)
|
2019-10-23 18:03:03 +00:00
|
|
|
TriggerCapture(rx, ry)
|
2019-10-25 15:29:52 +00:00
|
|
|
UiHide = false
|
2019-10-23 18:03:03 +00:00
|
|
|
end
|
2019-10-18 20:35:51 +00:00
|
|
|
x, y = x + CAPTURE_GRID_SIZE, y
|
|
|
|
end
|
|
|
|
-- +y
|
|
|
|
for i = 1, i, 1 do
|
2019-10-23 18:03:03 +00:00
|
|
|
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)
|
2019-10-25 15:29:52 +00:00
|
|
|
wait(CAPTURE_DELAY - 1)
|
|
|
|
UiHide = true
|
|
|
|
wait(1)
|
2019-10-23 18:03:03 +00:00
|
|
|
TriggerCapture(rx, ry)
|
2019-10-25 15:29:52 +00:00
|
|
|
UiHide = false
|
2019-10-23 18:03:03 +00:00
|
|
|
end
|
2019-10-18 20:35:51 +00:00
|
|
|
x, y = x, y + CAPTURE_GRID_SIZE
|
|
|
|
end
|
|
|
|
i = i + 1
|
|
|
|
-- -x
|
|
|
|
for i = 1, i, 1 do
|
2019-10-23 18:03:03 +00:00
|
|
|
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)
|
2019-10-25 15:29:52 +00:00
|
|
|
wait(CAPTURE_DELAY - 1)
|
|
|
|
UiHide = true
|
|
|
|
wait(1)
|
2019-10-23 18:03:03 +00:00
|
|
|
TriggerCapture(rx, ry)
|
2019-10-25 15:29:52 +00:00
|
|
|
UiHide = false
|
2019-10-23 18:03:03 +00:00
|
|
|
end
|
2019-10-18 20:35:51 +00:00
|
|
|
x, y = x - CAPTURE_GRID_SIZE, y
|
|
|
|
end
|
|
|
|
-- -y
|
|
|
|
for i = 1, i, 1 do
|
2019-10-23 18:03:03 +00:00
|
|
|
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)
|
2019-10-25 15:29:52 +00:00
|
|
|
wait(CAPTURE_DELAY - 1)
|
|
|
|
UiHide = true
|
|
|
|
wait(1)
|
2019-10-23 18:03:03 +00:00
|
|
|
TriggerCapture(rx, ry)
|
2019-10-25 15:29:52 +00:00
|
|
|
UiHide = false
|
2019-10-23 18:03:03 +00:00
|
|
|
end
|
2019-10-18 20:35:51 +00:00
|
|
|
x, y = x, y - CAPTURE_GRID_SIZE
|
|
|
|
end
|
|
|
|
i = i + 1
|
|
|
|
end
|
|
|
|
)
|
|
|
|
end
|