- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptHelperv7.6.lua
More file actions
Latest commit
325 lines (278 loc) · 6.81 KB
/
Copy pathscriptHelperv7.6.lua
File metadata and controls
325 lines (278 loc) · 6.81 KB
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
--made by Alexis :)
--version 7.6
-----------------
--start variables
-----------------
--troop-slot assignments
-------------------------
--Change the "0" to the Slot number of the troop
--if the troop isnt used, please put its value to "0"
localtroops= {
--elixir troops:
barb=0 ,
arch=0 ,
giant=0 ,
gob=0 ,
wbs=0 ,
loon=0 ,
wiz=0 ,
healer=0 ,
drag=0 ,
pekka=0 ,
--dark elixir troops:
minion=0 ,
hog=0 ,
valk=0 ,
gol=0 ,
witch=0 ,
lava=0 ,
--clan castle and heroes:
cc=0 ,
king=0 ,
queen=0 ,
warden=0 ,
--elixir spells:
light=0 ,
heal=0 ,
rage=0 ,
jump=0 ,
freeze=0 ,
--dark elixir spells:
poison=0 ,
earth=0 ,
haste=0 ,
--dark elixir cc spell
ccSpell=0
}
---------------------------
--type of screen when script was recorded (to convert coordinates)
--only important if u want to run on another device
--unimportant if you only use script on your own device
--enter "noretina" or "retina"
------------------------------------------------------
localrecScreenRes="retina"
--device rotation on recording
-- "3" if home button was on right
-- "4" if home button was on left
-----------------------------------
localrecRotation=3
--minimal sleep
--1000 or more recommended
localminSleep=1000
--sleep after troopbar swipe
--1000000 should be good
localtroopbarSleep=1000000
--troopbar set at beginning of script
----------------------
localtroopbarSet="+"
--DONT CHANGE ANYTHING BELOW HERE UNTIL YOU SEE:
--"START YOUR SCRIPT HERE:"
-----------------------------------------
--set the recording resolution
----------------------------------------
functionsetRecResolution()
ifrecScreenRes=="retina" then
recWidth=1536
recHeight=2048
elseifrecScreenRes=="noretina" then
recWidth=768
recHeight=1024
end
end
setRecResolution()
--the total troop count
localtotalTroopCount=0
--noAccesSlots
--will be defined in setTotalTroopCount()
---------------------------------
localnoAccesSlots
--current device rotation
-------------------------
localrotation=getOrientation()
--gets screen sizes of device
localwidth, height=getScreenResolution()
--x coordinate for slots left rot
----------------------------------
localslotCoo= {
recHeight*0.0583 , --slot 1
recHeight*0.1417 , --slot 2
recHeight*0.2251 , --slot 3
recHeight*0.3083 , --slot 4
recHeight*0.3916 , --slot 5
recHeight*0.4751 , --slot 6
recHeight*0.5583 , --slot 7
recHeight*0.6417 , --slot 8
recHeight*0.7251 , --slot 9
recHeight*0.8083 , --slot 10
recHeight*0.8917 , --slot 11
recHeight*0.9759--slot 12
}
slotCoo["x"] =recWidth*0.0195
-----------------
--end variables
-----------------
------------------
--start functions
------------------
--[[
function setVars( )
-- body
end
--]]
functionsetTotalTroopCount()
--set totalTroopCount
fori, vinpairs(troops) do
ifv~=0then
totalTroopCount=totalTroopCount+1
end
noAccesSlots=totalTroopCount-12
end
--print error
iftotalTroopCount<12ortotalTroopCount>24then
alert("ERROR!\
You entered too few or too many troops. See log for details.")
log("You entered too few or too many troops. ScriptHelper only supports 12-24 slots used.")
end
end
functionwrongSlotValueCheck()
fori, vinpairs(troops) do
ifv<0orv>24then
alert("ERROR! Something went wrong with the assigned slots. Please see the log for details.")
log(string.format("The assigned slot %q for the troop %q is incorrect.", v, i ));
end
end
end
--sets slot and xCoo correct
functionproperCoos()
ifrecRotation==4then
slotCoo["x"] =width-slotCoo["x"]
fori=1, 12do
slotCoo[i] =height-slotCoo[i]
end
end
end
--selects a slot
------------------
functionselectSlot(slot, troopName)
ifslot~=0then
iftroopbarSet=="-" then
ifslot-noAccesSlots>0then
slot=slot-noAccesSlots
--usleep(troopbarSleep)
else
setTroopbar("+")
end
--this happens of troopbar set ~= "-" -> troopBarSet = "+"
elseifslot>12then
setTroopbar("-")
slot=slot-noAccesSlots
end
tapp(slotCoo["x"], slotCoo[slot])
else
--print error
alert(string.format("ERROR!\
You did not enter a slot for the troop %q. See the log for details.", troop))
log(string.format("ERROR!\
You did not enter a slot for the troop %q.", troop))
end
end
--selects the troop, slot needs to be
--specified in varaible before
--------------------------------------
functionselect(troop)
iftroops[troop] ==nilthen
alert(string.format("ERROR!\
There is no troop named %q. See the log for details", troop))
log(string.format("ERROR! There is no troop named %q. See the readme for more details on the naming of troops.", troop))
else
selectSlot(troops[troop], troop)
end
end
--sets the troopsbar to positive or negative
---------------------------------------------
functionsetTroopbar(set)
ifset=="+" then
touchDown(1, recalcX(slotCoo["x"]), recalcY(slotCoo[1]))
usleep(troopbarSleep/2)
fori=1, 12, 1do
usleep(minSleep);
touchMove(1, recalcX(slotCoo["x"]), recalcY(slotCoo[i]))
end
usleep(minSleep)
touchUp(1, recalcX(slotCoo["x"]), recalcY(slotCoo[12]))
troopbarSet="+";
--sleep troop-min*13
end
ifset=="-" then
touchDown(1, recalcX(slotCoo["x"]), recalcY(slotCoo[12]))
usleep(troopbarSleep/2)
fori=12, 1, -1do
usleep(minSleep);
touchMove(1, recalcX(slotCoo["x"]), recalcY(slotCoo[i]))
end
usleep(minSleep)
touchUp(1, recalcX(slotCoo["x"]), recalcY(slotCoo[1]))
troopbarSet="-";
end
usleep(troopbarSleep- (minSleep*13-troopbarSleep/2) )
end
--recalcY(if iPad turned around)
--------------------
functionrecalcY(y)
ifrecRotation~=rotationthen
y=recHeight-y--height
end
y=convRes(y)
returny
end
--recalcX(if iPad turned around)
--------------------
functionrecalcX(x)
ifrecRotation~=rotationthen
x=recWidth-x--(width)
end
x=convRes(x)
returnx
end
--convert resolution
functionconvRes(coo)
ifrecScreenRes=="noretina" andwidth==1536then
coo=coo*2
elseifrecScreenRes=="retina" andwidth==768then
coo=coo/2
end
returncoo
end
--taps on a given point
----------------------------------------------
functiontapp(x, y)
tap(recalcX(x), recalcY(y))
usleep(minSleep);
end
--taps on a given point n amount of times
-------------------------------------------
functionmultiTapp(x, y, n)
ifres=="retina" andrecScreenRes=="noretina" then
x=x/2
y=y/2
elseifres=="noretina" andrecScreenRes=="retina" then
x=x*2
y=y*2
end
fori=1,ndo
tapp(x, y)
end
end
--activates the ability of the given hero
--selects the hero if he wasnt deployed first
--------------------------------------------------
functionability(hero)
select(hero)
end
properCoos()
setTotalTroopCount()
wrongSlotValueCheck()
----------------
--end functions
----------------
--START YOUR SCRIPT HERE: