-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy path_support_img_maker.lua
64 lines (49 loc) · 2.07 KB
/
_support_img_maker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
dir = scriptPath()
package.path = package.path .. ";" .. dir .. 'modules/?.lua'
setImagePath(dir)
local ankuluaUtils = require("ankulua-utils")
local scaling = require("scaling")
local game = require("game")
GameRegion = "EN"
GeneralImagePath = "image_" .. GameRegion .. "/"
local IMAGE_WIDTH = 1280
local IMAGE_HEIGHT = 720
local SCRIPT_WIDTH = 2560
local SCRIPT_HEIGHT = 1440
scaling.ApplyAspectRatioFix(SCRIPT_WIDTH, SCRIPT_HEIGHT, IMAGE_WIDTH, IMAGE_HEIGHT)
-- Single screenshot is enough
snapshot()
--Checks if Support Selection menu is up
local isSupportScreen = game.SUPPORT_SCREEN_REGION:exists(Pattern(GeneralImagePath .. "support_screen.png"):similar(.85))
local supportBound = Region(106,0,286,220)
local regionAnchor = Pattern(GeneralImagePath .. "support_region_tool.png")
local regionArray = regionFindAllNoFindException(Region(2100,0,300,1440), regionAnchor)
local screenBounds = Region(0,0,SCRIPT_WIDTH,SCRIPT_HEIGHT)
local datetime = os.date('%Y%m%d-%H%M%S')
local folder = 'support_' .. datetime .. '/'
os.execute('mkdir ' .. dir .. '/' .. folder)
local i = 0
for _, testRegion in ipairs(regionArray) do
-- At max two Servant+CE are completely on screen
if i > 1 then
break
end
if isSupportScreen then
supportBound:setY(testRegion:getY() - 70 + 68 * 2)
else -- Assume we are on Friend List
supportBound:setY(testRegion:getY() + 82)
supportBound = ankuluaUtils.AddX(supportBound, 10)
end
if ankuluaUtils.DoesRegionContain(screenBounds, supportBound) then
local servantBound = Region(supportBound:getX(), supportBound:getY(), 250, 88)
servantBound:save(folder .. 'servant_' .. i .. '.png')
local ceBound = Region(supportBound:getX(), supportBound:getY() + 160, supportBound:getW(), 50)
ceBound:save(folder .. 'ce_' .. i .. '.png')
i = i + 1
end
end
if i == 0 then
scriptExit("No support images were found. Make sure you're in the Support Selection or in the Friend List and that the correct GameRegion is set in the script.")
else
scriptExit(i .. " Servant and CE images have been stored in the folder '" .. folder .. "'")
end