-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrust_master.lua
294 lines (252 loc) · 6.39 KB
/
trust_master.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
-- v0.2.1
-- === Setup === --
Settings:setCompareDimension(true, 1080)
Settings:setScriptDimension(true, 1080)
setAlternativeClick(true)
UNKNOWN = "unknown"
EXIT = "exit"
QUEST_LIST = "quest_list"
MISSION_LIST = "mission_list"
COMPANION_LIST = "companion_list"
DEPART_SCREEN = "depart_screen"
BATTLE = "battle"
FIGHTING = "fighting"
RESULTS = "results"
UNIT_RESULTS = "unit_results"
ITEMS_OBTAINED = "items_obtained"
DISCONNECTED = "disconnected"
ENERGY_RECOVERY = "energy_recovery"
LAPIS_RESTORE = "lapis_restore"
UNIT_DATA = "unit_data"
DAILY_QUEST = "daily_quest"
FRIEND_REQUEST = "friend_request"
TIMEOUT = 20
FIGHTING_TIMEOUT = 120
ENERGY_WAIT = 60 * 5 * 10
RETRY_TIMEOUT = 5
MAX_RETRY = 12
retries = 0
function main()
state = QUEST_LIST
build_ui()
if (dim_screen) then
setBrightness(0)
end
if (slow_scan) then
setScanInterval(4)
end
while(true) do
if (print_state) then
toast(state)
print(state)
end
Settings:set("MinSimilarity", 0.8)
if (state == QUEST_LIST) then
state = quest_list()
elseif (state == MISSION_LIST) then
state = mission_list()
elseif (state == COMPANION_LIST) then
state = companion_list()
elseif (state == DEPART_SCREEN) then
state = depart_screen()
elseif (state == BATTLE) then
state = battle()
elseif (state == FIGHTING) then
state = fighting()
elseif (state == RESULTS) then
state = results()
elseif (state == UNIT_RESULTS) then
state = unit_results()
elseif (state == ITEMS_OBTAINED) then
state = items_obtained()
elseif (state == UNKNOWN) then
state = unknown()
elseif (state == DISCONNECTED) then
state = disconnected()
elseif (state == ENERGY_RECOVERY) then
state = energy_recovery()
elseif (state == LAPIS_RESTORE) then
state = lapis_restore()
elseif (state == UNIT_DATA) then
state = unit_data()
elseif (state == DAILY_QUEST) then
state = daily_quest()
elseif (state == FRIEND_REQUEST) then
state = friend_request()
else
break
end
wait(1)
end
end
function build_ui()
dialogInit()
addCheckBox("use_lapis", "Lapis Refill", false)
newRow()
addTextView("Pro Features")
newRow()
addCheckBox("dim_screen", "Dim Screen", false)
addCheckBox("slow_scan", "Save Battery", false)
newRow()
addTextView("Debugging")
newRow()
addCheckBox("print_state", "Show State Changes", false)
dialogShow("Trust Master")
end
function unknown()
if (retries > MAX_RETRY) then
return EXIT
end
local found_state
Settings:set("MinSimilarity", 0.9)
if (exists("disconnected/disconnected.png")) then
found_state = DISCONNECTED
elseif (exists("results/results.png", RETRY_TIMEOUT)) then
found_state = RESULTS
elseif (exists("battle/battle.png", RETRY_TIMEOUT)) then
found_state = BATTLE
elseif (exists("energy_recovery/energy_recovery.png", RETRY_TIMEOUT)) then
found_state = ENERGY_RECOVERY
elseif (exists("lapis_restore/lapis_restore.png", RETRY_TIMEOUT)) then
found_state = LAPIS_RESTORE
elseif (exists("unit_data/unit_data.png", RETRY_TIMEOUT)) then
found_state = UNIT_DATA
elseif (exists("companion_list/companion_list.png", RETRY_TIMEOUT)) then
found_state = COMPANION_LIST
elseif (exists("depart_screen/depart_screen.png", RETRY_TIMEOUT)) then
found_state = DEPART_SCREEN
elseif (exists("fighting/fighting.png", RETRY_TIMEOUT)) then
found_state = FIGHTING
elseif (exists("items_obtained/items_obtained.png", RETRY_TIMEOUT)) then
found_state = ITEMS_OBTAINED
elseif (exists("mission_list/mission_list.png", RETRY_TIMEOUT)) then
found_state = MISSION_LIST
elseif (exists("quest_list/quest_list.png", RETRY_TIMEOUT)) then
found_state = QUEST_LIST
elseif (exists("unit_results/unit_results.png", RETRY_TIMEOUT)) then
found_state = UNIT_RESULTS
elseif (exists("daily_quest/daily_quest.png", RETRY_TIMEOUT)) then
found_state = DAILY_QUEST
elseif (exists("friend_request/friend_request.png", RETRY_TIMEOUT)) then
found_state = FRIEND_REQUEST
else
retries = retries + 1
return UNKNOWN
end
retries = 0
return found_state
end
function daily_quest()
if (existsClick("daily_quest/close.png", TIMEOUT)) then
return QUEST_LIST
else
return UNKNOWN
end
end
function friend_request()
if (existsClick("friend_request/dont_request.png", TIMEOUT)) then
return QUEST_LIST
else
return UNKNOWN
end
end
function unit_data()
if (existsClick("unit_data/ok.png", TIMEOUT)) then
return UNKNOWN -- Update
else
return UNKNOWN
end
end
function lapis_restore()
if (existsClick("lapis_restore/yes.png", TIMEOUT)) then
return QUEST_LIST
else
return UNKNOWN
end
end
function energy_recovery()
if (use_lapis) then
if (existsClick("energy_recovery/lapis.png", TIMEOUT)) then
return LAPIS_RESTORE
else
return UNKNOWN
end
end
wait(ENERGY_WAIT)
if (existsClick("energy_recovery/back.png", TIMEOUT)) then
return QUEST_LIST
else
return UNKNOWN
end
end
function quest_list()
if (existsClick("quest_list/earth_shrine_exit.png", TIMEOUT)) then
return MISSION_LIST
else
return UNKNOWN
end
end
function mission_list()
if (existsClick("mission_list/next.png", TIMEOUT)) then
return COMPANION_LIST
else
return UNKNOWN
end
end
function companion_list()
if (existsClick("companion_list/rank.png", TIMEOUT)) then
return DEPART_SCREEN
else
return UNKNOWN
end
end
function depart_screen()
if (existsClick("depart_screen/depart.png", TIMEOUT)) then
return BATTLE
else
return UNKNOWN
end
end
function battle()
if (existsClick("battle/auto.png", TIMEOUT)) then
return FIGHTING
else
return UNKNOWN
end
end
function fighting()
if (waitVanish("fighting/fighting.png", FIGHTING_TIMEOUT)) then
return RESULTS
else
return UNKNOWN
end
end
function results()
if (existsClick("results/next.png", TIMEOUT)) then
return UNIT_RESULTS
else
return UNKNOWN
end
end
function unit_results()
if (existsClick("unit_results/results.png", TIMEOUT)) then
return ITEMS_OBTAINED
else
return UNKNOWN
end
end
function items_obtained()
if (existsClick("items_obtained/next.png", TIMEOUT)) then
return QUEST_LIST
else
return UNKNOWN
end
end
function disconnected()
if (existsClick("disconnected/ok.png", TIMEOUT)) then
return UNKNOWN
else
return UNKNOWN
end
end
main()