forked from brycole/gemstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgemhoarder.lic
More file actions
744 lines (673 loc) · 29.1 KB
/
gemhoarder.lic
File metadata and controls
744 lines (673 loc) · 29.1 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
=begin
# Title: gemhoarder
# Author: Caithris
# Creation Date: 1/25/2013
# Version: 0.7
# Description: Based off of loot-be-gone's stockpile option with changes listed below.
# By Shi'larra's user's request, fills jars from your gemsack.
# Takes empty jars from your chest
# Puts full jars in your wardrobe
# Partially filled jars go in the bin.
# Raid function
# Manually set gem amounts
# Multi-locker edition, premium/plat only.
# Checks if you have gems already jarred in other lockers.
#
# Latest fix: Fixed it so the updating locker tags do not disrupt cataloguing new lockers
# NEW - Updated, new functions alpha and search
#
# CURRENT ISSUES: gemhoarder does NOT like multiple jars of the same stuff.
=end
silence_me
unless script.vars[1]
script.vars[1]="none"
end
if script.vars[1] =~ /raid/
unless script.vars[2]
output = "Please specify a gem raid or use \"all\" to select all.\n"
output.concat "Usage:\n"
output.concat " ;gemhoarder raid <gem|all> [amount]\n"
respond output
exit
end
unless script.vars[3]
output = "defaulting to 1 gem to raid.\n"
respond output
script.vars[3]=1
end
end
if script.vars[1] =~ /help/
output = "Usage: ;gemhoarder [help|newlocker|list|alpha|search|forget]\n"
output.concat " help: prints out this list.\n"
output.concat " newlocker: add a new locker to your list.\n"
output.concat " list: list all gems currently in jars.\n"
output.concat " alpha: list all gems currently in jars in alphabetical order.\n"
output.concat " search <string>: list all gems currently in jars that match a search string.\n"
output.concat " forget: forget the gem contents in all your lockers.\n"
output.concat " raid <gem> <amount>: raid <gem> where gem can be \"all\" for the specified amount.\n"
output.concat " set <gem> <amount> <full>: set the selected gem to the specified amount.\n"
output.concat " \n"
output.concat " set example: ;gemhoarder \"golden beryl gems\" 15 false\n"
output.concat " another set example: ;gemhoarder \"fire opals\" 0 false Solhaven\n"
output.concat " \n"
output.concat " to delete a jar, please use an amount of 0\n"
output.concat " to move a jar to another locker, please first delete the jar, and then use the set command with an amount, or run this script at your new locker location.\n"
respond output
elsif script.vars[1] =~ /list/
output = " gem count full location\n"
output.concat " --- ----- ---- ------------\n"
for jar in CharSettings[:jars].sort { |a,b| b[:count] <=> a[:count] }
if jar[:full] =~ /full/
jar[:full] = full
end
if jar[:full] =~ /false/
jar[:full]= false
end
output.concat "#{jar[:gem].rjust(35)} #{jar[:count].to_s.rjust(2)} #{jar[:full].to_s.rjust(8)} #{jar[:location].to_s.ljust(30)}\n"
end
respond output
elsif script.vars[1] =~ /alpha/
output = " gem count full location\n"
output.concat " --- ----- ---- ------------\n"
for jar in CharSettings[:jars].sort { |a,b| a[:gem] <=> b[:gem] }
if jar[:full] =~ /full/
jar[:full] = full
end
if jar[:full] =~ /false/
jar[:full]= false
end
output.concat "#{jar[:gem].rjust(35)} #{jar[:count].to_s.rjust(2)} #{jar[:full].to_s.rjust(8)} #{jar[:location].to_s.ljust(30)}\n"
end
respond output
elsif script.vars[1] =~ /search/
output = " gem count full location\n"
output.concat " --- ----- ---- ------------\n"
for jar in CharSettings[:jars].sort { |a,b| a[:gem] <=> b[:gem] }
if jar[:gem] =~ /#{script.vars[2]}/ then
output.concat "#{jar[:gem].rjust(35)} #{jar[:count].to_s.rjust(2)} #{jar[:full].to_s.rjust(8)} #{jar[:location].to_s.ljust(30)}\n"
end
end
respond output
elsif script.vars[1] =~ /set/
unless script.vars[2]
output = "Please specify which gem to modify.\n"
respond output
exit
end
unless script.vars[3]
output = "jar amount not specified, defaulting to removal.\n"
respond output
script.vars[3]=0
end
unless script.vars[4]
output = "jar full true/false not specified, defaulting to false.\n"
respond output
script.vars[4]=false
end
if script.vars[4] =~ /false/ then
script.vars[4] = false
elsif script.vars[4] =~ /true/ then
script.vars[4] = true
end
unless script.vars[5]
fput "location"
script.vars[5] = matchfind "current location is ? or somewhere close to it."
output = "setting location to #{script.vars[5]}.\n"
respond output
end
gem=script.vars[2]
count=script.vars[3].to_i
full=script.vars[4]
location=script.vars[5]
jar_hash = CharSettings[:jars].find { |j| j[:gem] == gem }
unless jar_hash
jar_hash = CharSettings[:jars].find { |j| j[:gem] == gem + "s" }
end
if count > 0
output="#{gem}, #{count}, #{full}, #{location} have been added.\n"
respond output
CharSettings[:jars].delete_if { |j| j[:gem] == gem }
CharSettings[:jars].push(h={ :gem => gem, :count => count, :full => full, :location => location})
else
output = "Removing #{gem} from the list.\n"
respond output
CharSettings[:jars].delete_if { |j| j[:gem] == gem }
end
exit
elsif script.vars[1] =~ /forget/
CharSettings[:jars]=nil
CharSettings[:known_lockers]=nil
output = "Locker contents forgotten.\n"
respond output
exit
else
if UserVars.gemsack.nil? or UserVars.gemsack.empty?
echo 'error: gemsack is not set. (;set change gemsack <container name>)'
exit
end
if UserVars.lootsack.nil? or UserVars.lootsack.empty?
echo 'error: lootsack is not set. (;set change lootsack <container name>)'
exit
end
unless gemsack = (GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.gemsack.strip)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.gemsack).sub(' ', ' .*')}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.gemsack).sub(' ', ' .*')}/i })
echo 'error: failed to find your gemsack'
exit
end
unless lootsack = (GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.lootsack.strip)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}/i })
echo 'error: failed to find your lootsack'
exit
end
close_gemsack = false
close_lootsack = false
open_result = dothistimeout "open ##{gemsack.id}", 5, /^You open|^You carefully|^You unfasten|^That is already open\.$/
if open_result =~ /^You open|^You carefully|^You unfasten/
close_gemsack = true
else
dothistimeout "look in ##{gemsack.id}", 5, /In .*? you see/
if gemsack.contents.nil?
echo 'error: failed to find gemsack contents'
exit
end
end
open_result = dothistimeout "open ##{lootsack.id}", 5, /^You open|^You carefully|^You unfasten|^That is already open\.$/
if open_result =~ /^You open|^You carefully|^You unfasten/
close_lootsack = true
else
dothistimeout "look in ##{lootsack.id}", 5, /In .*? you see/
if lootsack.contents.nil?
echo 'error: failed to find lootsack contents'
exit
end
end
empty_hands
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
if CharSettings[:jars].nil? || script.vars[1]=~/newlocker/
fput "open locker"
jars = ["jar", "beaker", "bottle"]
jars.each { |jar|
echo "Moving all #{jar}s from your wardrobe into your chest"
output="You put"
while output =~ /You put/ do
dothistimeout "get #{jar} from wardrobe", 3, /^You remove|Get what/
output = dothistimeout "put my #{jar} in chest", 3, /^You put|I could not find/
end
}
jars.each { |jar|
output="You put"
echo "Moving all #{jar}s from your bin into your chest"
while output =~ /You put/ do
dothistimeout "get #{jar} from bin", 3, /^You remove|Get what/
output = dothistimeout "put my #{jar} in chest", 3, /^You put|I could not find/
end
}
end
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist=".*?" noun="(?:locker|bin)"/
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|chest)"/
fput "location"
location = matchfind "current location is ? or somewhere close to it."
locker_id = $1
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
if locker_contents
if CharSettings[:jars].nil?
CharSettings[:jars] = Array.new
CharSettings[:empty_jar_count] = 0
script.vars[1]="newlocker"
broken=true
while broken==true do
broken=false
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist="(\d+)" noun="chest"/
locker_id = $1
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|chest)"/
locker_id = $1
end
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|bottle|beaker)$/ }.each { |jar|
unless jar.after_name.nil?
look_result = dothistimeout "look in ##{jar.id} from ##{locker_id}", 3, /^Inside .*? you see [0-9]+ portion|I could not find what you were referring to/
if look_result=~/I could not find what you were referring to/ then
broken=true
break
end
if look_result =~ /^Inside .*? you see ([0-9]+) portion/
count = $1.to_i
gem = jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '')
full = look_result.include?('It is full')
if full
output=dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /You remove|Get what/
if output=~/Get what/
broken=true
break
end
fput "put ##{jar.id} in wardrobe"
else
output=dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /You remove|Get what/
if output=~/Get what/
broken=true
break
end
fput "put ##{jar.id} in bin"
end
CharSettings[:jars].push(h={ :gem => gem, :count => count, :full => full, :location => location})
end
end
}
end
CharSettings[:known_lockers]=Array.new
CharSettings[:known_lockers].push(location)
elsif script.vars[1]=~/newlocker/
broken=true
while broken==true do
broken=false
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist="(\d+)" noun="chest"/
locker_id = $1
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|chest)"/
locker_id = $1
end
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|bottle|beaker)$/ }.each { |jar|
unless jar.after_name.nil?
look_result = dothistimeout "look in ##{jar.id} from ##{locker_id}", 3, /^Inside .*? you see [0-9]+ portion|I could not find what you were referring to/
if look_result=~/I could not find what you were referring to/ then
broken=true
break
end
if look_result =~ /^Inside .*? you see ([0-9]+) portion/
count = $1.to_i
gem = jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '')
full = look_result.include?('It is full')
if full
fput "get ##{jar.id} from ##{locker_id}"
fput "put ##{jar.id} in wardrobe"
else
fput "get ##{jar.id} from ##{locker_id}"
fput "put ##{jar.id} in bin"
end
CharSettings[:jars].push(h={ :gem => gem, :count => count, :full => full, :location =>location })
end
end
}
end
CharSettings[:known_lockers].push(location)
end
unless CharSettings[:known_lockers].include?(location)
output="WARNING! This locker doesn't appear to have been recorded!\nIf you really want to store gems to this locker prior to recording, ;send continue.\nTo record this locker, kill gemhoarder and rerun with the newlocker option.\n"
respond output
waitfor "continue"
end
not_suitable = Array.new
#####
#RAID GOING HERE
####
if script.vars[1]=~/raid/
count=script.vars[3].to_i
gem_bin=Array.new
gem_wardrobe=Array.new
fput "location"
preserve=0
location = matchfind "current location is ? or somewhere close to it."
CharSettings[:jars].each { |gem_hash|
if gem_hash[:full] =~ /full/
gem_hash[:full] = full
end
if gem_hash[:full] =~ /false/
gem_hash[:full]= false
end
if gem_hash[:location] == location
if script.vars[2] == "all"
preserve=1
if gem_hash[:full]
gem_wardrobe.push(gem_hash[:gem])
elsif gem_hash[:count].to_i >= count.to_i
gem_bin.push(gem_hash[:gem])
end
else
if gem_hash[:gem]==script.vars[2]
if gem_hash[:full]
#echo "pushing to gem_wardrobe"
gem_wardrobe.push(gem_hash[:gem])
elsif gem_hash[:count].to_i >= count.to_i
#echo "pushing to gem_bin"
gem_bin.push(gem_hash[:gem])
end
elsif gem_hash[:gem]==script.vars[2]+'s'
if gem_hash[:full]
gem_wardrobe.push(gem_hash[:gem])
elsif gem_hash[:count].to_i >= count.to_i
gem_bin.push(gem_hash[:gem])
end
elsif gem_hash[:gem]==script.vars[2]+'es'
if gem_hash[:full]
gem_wardrobe.push(gem_hash[:gem])
elsif gem_hash[:count].to_i >= count.to_i
gem_bin.push(gem_hash[:gem])
end
end
end
end
}
gem_wardrobe.each { |gem|
#echo gem
gem.gsub!(/large |medium |small |tiny |some /, '')
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist=".*?" noun="(wardrobe)"|already open/
status_tags
if open_result =~ /exist="(\d+)" noun="(wardrobe)"/
locker_id = $1
locker_contents = GameObj.containers[locker_id]
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
if locker_contents
if CharSettings[:jars].any? { |jar| (jar[:gem] =~ /^#{gem.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/) and (jar[:count].to_i >= count.to_i) }
if jar = locker_contents.find { |jar| jar.after_name.gsub(/containing |large |medium |small |tiny |some /, '') =~ /^#{gem.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/ }
jar_hash = CharSettings[:jars].find { |j| j[:gem] == jar.after_name.sub(/^containing |large |medium |small |tiny |some /, '') }
jar_result=dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /^You remove|Get what?/
if jar_result=~/^You remove/ then
count.times {
dothistimeout "shake ##{jar.id}", 3, /^You .*shake/
if GameObj.right_hand.id != jar.id
obj = GameObj.right_hand
elsif GameObj.left_hand.id != jar.id
obj = GameObj.left_hand
end
dothistimeout "put ##{obj.id} in ##{gemsack.id}", 3, /^You put/
jar_hash[:count] = jar_hash[:count] - 1
jar_hash[:full] = false
}
if jar_hash[:count] < 1
CharSettings[:jars].delete(jar_hash)
CharSettings[:empty] = CharSettings[:empty] + 1
dothistimeout "put ##{jar.id} in chest", 3, /^You (?:put|place)/
end
dothistimeout "put ##{jar.id} in bin", 3, /^You (?:put|place)/
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
true
else
echo "Sorry. Locker has refreshed. Please re-start ;gemhoarder raid."
exit false
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
false
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
false
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker contents'
false
end
else
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker'
false
end
}
gem_bin.each { |gem|
gem.gsub!(/large |medium |small |tiny |some /, '')
####raid bin
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist=".*?" noun="(?:locker|bin)"/
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|bin)"/
locker_id = $1
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
if locker_contents
if CharSettings[:jars].any? { |jar| (jar[:gem] =~ /^#{gem.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/) and (jar[:count] >= count.to_i+preserve.to_i) }
if jar = locker_contents.find { |jar| jar.after_name.gsub(/containing |large |medium |small |tiny |some /, '') =~ /^#{gem.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/ }
jar_hash = CharSettings[:jars].find { |j| j[:gem] == jar.after_name.sub(/^containing |large |medium |small |tiny |some /, '') }
jar_result=dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /^You remove|Get what?/
if jar_result=~/^You remove/ then
count.to_i.times {
dothistimeout "shake ##{jar.id}", 3, /^You .*shake/
if GameObj.right_hand.id != jar.id
obj = GameObj.right_hand
elsif GameObj.left_hand.id != jar.id
obj = GameObj.left_hand
end
dothistimeout "put ##{obj.id} in ##{gemsack.id}", 3, /^You put/
jar_hash[:count] = jar_hash[:count] - 1
jar_hash[:full] = false
}
if jar_hash[:count] < 1
CharSettings[:jars].delete(jar_hash)
CharSettings[:empty] = CharSettings[:empty] + 1
dothistimeout "put ##{jar.id} in chest", 3, /^You (?:put|place)/
end
dothistimeout "put ##{jar.id} in bin", 3, /^You (?:put|place)/
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
true
else
echo "Sorry. Locker has refreshed. Please restart ;gemhoarder raid"
exit
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
false
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
false
end
else
#dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker contents'
false
end
else
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker'
false
end
}
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
end
########### end new section
unless (script.vars[1]=~/newlocker/ or script.vars[1]=~/raid/)
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist="(\d+)" noun="bin"/
locker_id = $1
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|bin)"/
locker_id = $1
end
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
for jar in locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|beaker|bottle)$/ }
if jar.after_name =~ /^containing /
gem_list = gemsack.contents.find_all { |obj| (jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '') =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').sub(/x\b/, 'xe?').gsub(/\b\s/, 's? ')}s?$/) }
gem_list.delete_if { |obj| not_suitable.include?(obj.id) }
jar_hash = CharSettings[:jars].find { |j| j[:gem] == jar.after_name.gsub(/^containing |large |medium |small |tiny |some /, '') }
unless gem_list.empty?
dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /^You remove/
for gem in gem_list
result = dothistimeout "_drag ##{gem.id} ##{jar.id}", 3, /^You add|is full|does not appear to be a suitable container for/
if result =~ /^You add .* filling it/
jar_hash[:count] = jar_hash[:count] + 1
jar_hash[:full] = true
fput "put ##{jar.id} in wardrobe"
elsif result =~ /^You add/
jar_hash[:count] = jar_hash[:count] + 1
elsif result =~ /is full/
jar_hash[:full] = true
fput "put ##{jar.id} in wardrobe"
dothistimeout "put ##{gem.id} in ##{gemsack.id}", 3, /^You put/
break
elsif result =~ /does not appear to be a suitable container for/
dothistimeout "put ##{gem.id} in ##{lootsack.id}", 3, /^You put/
not_suitable.push(gem.id)
else
dothistimeout "put ##{gem.id} in ##{gemsack.id}", 3, /^You put/
end
end
if checkright
dothistimeout "put ##{jar.id} in ##{locker_id}", 3, /^You (?:put|place)/
end
end
else
fput "get ##{jar.id} in ##{locker_id}"
fput "put ##{jar.id} in chest"
end
end
end
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
status_tags
open_result = dothistimeout 'open locker', 5, /exist=".*?" noun="(?:locker|chest)"/
status_tags
if open_result =~ /exist="(\d+)" noun="(locker|chest)"/
locker_id = $1
locker_contents = GameObj.containers[locker_id]
unless locker_contents
dothistimeout "look in ##{locker_id}", 3, /^In the/
locker_contents = GameObj.containers[locker_id]
end
if locker_contents
not_suitable = Array.new
gem_hoard = Array.new
for jar in CharSettings[:jars]
gem_hoard.push(jar[:gem])
end
other_locker=Array.new
squelch=Array.new
unless script.vars[1]=~/newlocker/ or script.vars[1] =~/raid/
for jar in locker_contents.find_all { |obj| obj.noun =~ /^(?:jar|beaker|bottle)$/ }
gem_count = Hash.new
gemsack.contents.each { |obj|
if (obj.type =~ /gem/) and (obj.name !~ /oblivion quartz$|doomstone|urglaes fang/) and not gem_hoard.any?{ |op| op.gsub(/^containing |large |medium |small |tiny |some /, '') =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/} and not locker_contents.any? { |o| o.after_name.gsub(/^containing |large |medium |small |tiny |some /, '') =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/ and not not_suitable.include?(obj.id)}
gem_count[obj.name.gsub(/large |medium |small |tiny |some /, '')] = gem_count[obj.name.gsub(/large |medium |small |tiny |some /, '')].to_i + 1
elsif gem_hoard.any?{ |op| op.gsub(/^containing |large |medium |small |tiny |some /, '') =~ /^#{obj.name.gsub(/large |medium |small |tiny |some /, '').sub(/y\b/, '(?:y|ie)').sub(/z\b/, 'ze?').gsub(/\b\s/, 's? ')}s?$/}
other_locker.push(obj.name.gsub(/^containing |large |medium |small |tiny |some /, ''))
end
}
next if gem_count.empty?
gem_name = nil
gem_num = 0
gem_count.each_pair { |name,num|
if num > gem_num
gem_name = name
gem_num = num
end
}
if not squelch.include?(gem_name)
dothistimeout "get ##{jar.id} from ##{locker_id}", 3, /^You remove/
end
jar_hash = nil
gemsack.contents.each { |obj|
if obj.name.gsub(/large |medium |small |tiny |some /, '') == gem_name and not squelch.include?(gem_name)
result = dothistimeout "_drag ##{obj.id} ##{jar.id}", 3, /filling it|^You (?:add|put)|is full|does not appear to be a suitable container for|Not all drag and drop possibilities will/
if result =~ /^You add .* filling it/
jar_hash[:count] = jar_hash[:count] + 1
jar_hash[:full] = true
dothistimeout "put ##{jar.id} in wardrobe", 3, /^You put/
break
elsif result =~ /^You put/
dothistimeout "put ##{jar.id} in ##{lootsack.id}", 3, /^You put/
saveobjname=obj.name.gsub(/large |medium |small |tiny |some /, '');
gem = lootsack.contents.find { |obj| obj.id == jar.id }.after_name.gsub(/^containing |large |medium |small |tiny |some /, '')
dothistimeout "get ##{jar.id}", 3, /^You remove/
if gem_hoard.include?(gem)
fput "shake ##{jar.id}"
fput "put ##{jar.id} in chest"
fput "put left in ##{gemsack.id}"
unless other_locker.include?(gem)
squelch.push(saveobjname)
other_locker.push(gem)
end
break
else
jar_hash = { :gem => gem, :count => 1, :full => false, :location => location }
CharSettings[:jars].push(jar_hash)
end
elsif result =~ /is full/
dothistimeout "put ##{obj.id} in ##{gemsack.id}", 3, /^You put/
jar_hash[:full] = true
dothistimeout "put ##{jar.id} in wardrobe", 3, /^You put/
break
elsif result =~ /^You add/
jar_hash[:count] = jar_hash[:count] + 1
elsif result =~ /does not appear to be a suitable container for/
not_suitable.push(obj.id)
fput "put ##{obj.id} in ##{lootsack.id}"
elsif result =~ /Not all drag and drop possibilities will/
fput "put ##{obj.id} in ##{gemsack.id}"
fput "put ##{jar.id} in wardrobe"
end
end
}
if checkright
dothistimeout "put ##{jar.id} in bin", 3, /^You (?:put|place)/
end
end
end
end
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
fill_hands
else
dothistimeout "close locker", 1, /^You close|That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker contents'
end
else
dothistimeout "close locker", 1, /^You close|^That is already closed|^You hear the faint\.$/
echo 'error: failed to find locker'
end
end
if script.vars[1]=~/newlocker/
output = "New locker has been checked, sorted, and saved. Please re-run the script without arguments to deposit gems.\n"
output.concat "Please make sure to run \";gemhoarder newlocker\" at any other locker you are storing gems in before depositing here!\n"
respond output
end
unless other_locker.empty?
output = "Gems not lockered due to being already in another locker:\n"
output.concat " gem count full location\n"
output.concat " --- ----- ---- --------\n"
other_locker.each {|gem|
jar_hash = CharSettings[:jars].find { |j| j[:gem] == gem }
unless jar_hash
jar_hash = CharSettings[:jars].find { |j| j[:gem] == gem + "s" }
end
unless jar_hash[:full]
output.concat "#{jar_hash[:gem].rjust(35)} #{jar_hash[:count].to_s.rjust(2)} #{jar_hash[:full].to_s.rjust(8)} #{jar_hash[:location].to_s.ljust(30)}\n"
end
}
respond output
end
end
if close_gemsack
fput "close ##{gemsack.id}"
end
if close_lootsack
fput "close ##{lootsack.id}"
end
fill_hands