-
Notifications
You must be signed in to change notification settings - Fork 0
/
macro.ts
284 lines (242 loc) · 7.65 KB
/
macro.ts
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
#macro looper
:vars
setVar $count 0
setVar $script "(macro)"
setVar $scriptname "$playerName's custom macro"
setVar $version "v. 1.1"
#setVar $cn9 "OFF"
#setVar $delay 200
#setVar $macro ""
#setVar $loops 1
#setVar $oldmac ""
#setVar $ty_mac_cn9 "OFF"
#setVar $ty_mac_activate "OFF"
#saveVar $ty_mac_activate
:load_save_vars
loadVar $TyMacroSaved
if ($TyMacroSaved)
loadVar $ty_mac_cn9
loadVar $ty_mac_delay
loadVar $ty_mac_macro
loadVar $ty_mac_loops
loadVar $ty_mac_oldmac
loadVar $ty_mac_activate
else
setVar $ty_mac_cn9 "OFF"
setVar $ty_mac_delay 200
setVar $ty_mac_macro ""
setVar $ty_mac_loops 1
setVar $ty_mac_oldmac ""
setVar $ty_mac_activate "OFF"
saveVar $ty_mac_cn9
saveVar $ty_mac_delay
saveVar $ty_mac_macro
saveVar $ty_mac_loops
saveVar $ty_mac_oldmac
saveVar $ty_mac_activate
setVar $TyMacroSaved 1
saveVar $TyMacroSaved
end
:main
getWord CURRENTLINE $location 1
if ($location = "Command")
elseif ($location = "Citadel")
elseif ($location = "Planet")
elseif ($location = "Computer")
else
setVar $location "Unknown"
end
getLength $scriptname $max
getLength $version $len
goSub :checkmax
:ansimenu
killalltriggers
echo "[2J"
echo ANSI_6 "**-" ansi_2 "=" ansi_9 "("
setVar $text $scriptname
goSub :addspc
setVar $scriptdisplay $text
echo ansi_15 $scriptdisplay ansi_9 ")" ansi_2 "=" ansi_6 "-*"
echo ANSI_6 "-" ansi_2 "=" ansi_9 "("
setVar $text $version
goSub :addspc
setvar $verdisplay $text
echo ansi_15 $verdisplay ansi_9 ")" ansi_2 "=" ansi_6 "-**"
echo ansi_14 "1." ansi_15 " Macro String : " ansi_9 "[" ansi_6 $ty_mac_macro ansi_9 "]*"
echo ansi_14 "2." ansi_15 " Loops : " ansi_9 "[" ansi_6 $ty_mac_loops ansi_9 "]*"
echo ansi_14 "3." ansi_15 " CN9 emulation : " ansi_9 "[" ansi_6 $ty_mac_cn9 ansi_9 "]*"
echo ansi_14 "4." ansi_15 " MS Delay : " ansi_9 "[" ansi_6 $ty_mac_delay ansi_9 "]*"
echo ansi_14 "5." ansi_15 " Activate CN9 : " ansi_9 "[" ansi_6 $ty_mac_activate ansi_9 "]*"
echo ansi_14 "C." ansi_15 " run script **"
getConsoleInput $choice SINGLEKEY
if ($choice = "1")
echo "*Macro : "
getConsoleInput $ty_mac_macro
echo "[2J"
goto :ansimenu
elseif ($choice = "2")
echo "*Loops : "
getConsoleInput $ty_mac_loops
echo "[2J"
goto :ansimenu
elseif ($choice = "3")
if ($ty_mac_cn9 = "OFF")
setVar $ty_mac_cn9 "ON"
goSub :emuCN9
elseif ($ty_mac_cn9 = "ON")
setVar $ty_mac_cn9 "OFF"
setVar $ty_mac_macro $ty_mac_oldmac
end
echo "[2J"
goto :ansimenu
elseif ($choice = "4")
echo "*Delay : "
getConsoleInput $ty_mac_delay
echo "[2J"
goto :ansimenu
elseif ($choice = "5")
if ($ty_mac_activate = "OFF")
setVar $ty_mac_activate "ON"
else
setVar $ty_mac_activate "OFF"
end
echo "[2J"
goto :ansimenu
elseif ($choice = "c")
goto :test_macro
else
echo "[2J"
goto :ansimenu
end
:test_macro
saveVar $ty_mac_cn9
saveVar $ty_mac_delay
saveVar $ty_mac_macro
saveVar $ty_mac_loops
saveVar $ty_mac_oldmac
saveVar $ty_mac_activate
setVar $TyMacroSaved 1
saveVar $TyMacroSaved
if ($ty_mac_activate = "ON")
:check_cn9
setVar $line CURRENTLINE
getWord $line $chk_prompt 1
if ($chk_prompt = "Command") OR ($chk_prompt = "Citadel")
send "cn"
waitFor "Abort display on keys"
setVar $line CURRENTLINE
getWord $line $cn9_status 7
if ($cn9_status = "SPACE")
send "9"
end
send "qq"
else
echo ansi_12 "*Cannot Check CN9 from this prompt - " ansi_13 " Proceed : " ansi_12 " Y " ansi_11 "/" ansi_12 " N *"
getConsoleInput $proceed_bad_prompt SINGLEKEY
if ($proceed_bad_prompt = "Y") OR ($proceed_bad_prompt = "y")
goto :send_macro
else
halt
end
end
end
:send_macro
replaceText $ty_mac_macro #42 "*"
killalltriggers
send $ty_mac_macro
setDelayTrigger complete :loop_macro 2000
pause
:loop_macro
if ($ty_mac_cn9 = "Off")
getLength $ty_mac_macro $maclen
elseif ($cn9 = "On")
getLength $ty_mac_oldmac $maclen
end
echo "*Begin Loop ? (y/n)*"
getConsoleInput $yesno SINGLEKEY
if ($yesno = "y")
goto :begin_loop
elseif ($yesno = "n")
goto :ansimenu
else
goto :loop_macro
end
:begin_loop
send "'" $script " : beginning loop...*"
setVar $count 1
:fire_macro
if ($count >= $ty_mac_loops)
goto :done
end
send $ty_mac_macro
add $count 1
setDelayTrigger 2 :fire_macro $ty_mac_delay
pause
:done
send "'" $script " : " $ty_mac_loops " loops completed*"
halt
#------------------------------#####SUBROUTINES#####------------------------------------#
:addspc
getLength $text $len
if ($len < $max)
setVar $spaces ($max - $len)
if ($spaces = 1)
setVar $text " " & $text
else
setVar $spaces ($spaces / 2)
setVar $cnt 0
:addfront
if ($cnt < $spaces)
add $cnt 1
setVar $text " " & $text
goto :addfront
end
setVar $cnt 0
:addback
if ($cnt < $spaces)
add $cnt 1
setVar $text $text & " "
goto :addback
end
getLength $text $len
if ($len < $max)
setVar $text " " & $text
end
end
end
return
:checkMax
if ($len > $max)
setVar $max $len
end
return
:emuCN9
killalltriggers
if ($ty_mac_macro = $newmac)
setVar $ty_mac_macro $ty_mac_oldmac
end
getLength $ty_mac_macro $len
setVar $count 1
setVar $ty_mac_oldmac $ty_mac_macro
setVar $newmac ""
setVar $last_char "Text"
while ($count <= $len)
cutText $ty_mac_macro $char $count 1
isNumber $test_char $char
if ($test_char = 1)
if ($last_char = "Number")
setVar $newmac $newmac & $char
setVar $last_char "Number"
else
setVar $newmac $newmac & " " & $char
setVar $last_char "Number"
end
else
setVar $newmac $newmac & " " & $char
setVar $last_char "Text"
end
add $count 1
end
setVar $newmac $newmac & " "
setVar $ty_mac_macro $newmac
return