forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean-leather.lic
158 lines (140 loc) · 6.95 KB
/
clean-leather.lic
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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#clean-leather
=end
custom_require.call(%w[common common-items common-crafting common-travel common-money])
# Sample script call: ;clean-leather backpack troll skin rucksack quick
class CleanLeather
def initialize
arg_definitions = [
[
{ name: 'source', regex: /\w+/, optional: false, description: 'REQUIRED: Our source container (e.g. bundle, backpack, etc.)' },
{ name: 'animal', regex: /\w+/, optional: false, description: 'REQUIRED: The animal the rawhide came from (e.g. troll, kobold, etc.)' },
{ name: 'hide', regex: /\w+/, optional: false, description: 'REQUIRED: The noun of the type of rawhide (e.g. skin, pelt, bones, etc.)' },
{ name: 'storage', regex: /\w+/, optional: false, description: 'REQUIRED: The container to put finished leather in. Must be different than source container.' },
{ name: 'speed', regex: /normal|quick|careful/i, optional: true, description: 'OPTIONAL: How quickly to scrape (normal|quick|careful). Defaults to normal.' },
{ name: 'max_apply', regex: /max/i, optional: true, description: 'OPTIONAL: Specify "max" to apply preservative the maximum number of times.' },
{ name: 'debug', regex: /debug/i, optional: true, description: 'OPTIONAL: Output debug info.' }
]
]
args = parse_args(arg_definitions)
# Grab our yaml crafting settings if they exist
@settings = get_settings
@bag = @settings.crafting_container
@bag_items = @settings.crafting_items_in_container
@belt = @settings.outfitting_belt
engineering_room = @settings.engineering_room
outfitting_room = @settings.outfitting_room
# Set the proper stock rooms, preservative, and order number depending on whether we're
# cleaning hides or bones.
if args.hide =~ /^bones?$/i
@stock_room = get_data('crafting')['shaping'][@settings.hometown]['tool-room']
@room = engineering_room
@preservative = 'bleaching solution'
@order_number = '7'
else
@stock_room = get_data('crafting')['tailoring'][@settings.hometown]['tool-room']
@room = outfitting_room
@preservative = 'tanning lotion'
@order_number = '8'
end
# Set our script args to variables
source = args.source
animal = args.animal
hide = args.hide
storage = args.storage
speed = args.speed || 'normal'
full_preservative = args.max_apply
# Debug output
if args.debug
respond("ROOM AND RESTOCK SETTINGS:")
respond(" @stock_room (the room to restock our preservative) is set to: #{@stock_room}")
respond(" @room (the room we'll clean leather in) is set to: #{@room}")
respond(" @preservative (the preservative we'll use) is set to: #{@preservative}")
respond(" @order_number (the order number to restock preservative) is set to: #{@order_number}")
respond("")
respond("SCRIPT CALL ARGUMENT SETTINGS")
respond(" source (container we get rawhide from) is set to: #{source}")
respond(" animal (the animal the hide or bones are from) is set to: #{animal}")
respond(" hide (the noun of the rawhide) is set to: #{hide}")
respond(" storage (the container we'll store clean hides in) is set to: #{storage}")
respond(" speed (the speed we'll scrape the hide) is set to: #{speed}")
respond(" max_apply (apply preservative once or max) is set to: #{max_apply}")
end
clean_leather(source, animal, hide, storage, speed, full_preservative)
end
def clean_leather(source, animal, hide, storage, speed, full_preservative)
# Walk to the room we'll be crafting in (set in yaml)
# Stow anything in our hands
DRCT.walk_to(@room)
DRCI.stow_hands
# Get as many skins as we have in the source container, cleaning them, then preserving
# them, then putting them in the storage container.
loop do
case DRC.bput("get #{animal} #{hide} from my #{source}", /^You get/i, /^You carefully remove/i, /^What were you/i, /What do you want to get?/i)
when /^You get/i, /^You carefully remove/i
scrape_leather(hide, speed)
apply_preservative(animal, hide, storage, full_preservative)
when /^What were you/i, /What do you want to get?/i
DRC.message("Done with all #{animal} #{hide}s.")
break
else
DRC.message("Unable to get the rawhide. Please submit an issue on GitHub: https://github.com/rpherbig/dr-scripts/issues")
DRCI.stow_hands
end
end
end
def scrape_leather(hide, speed)
DRCC.get_crafting_item('scraper', @bag, @bag_items, @belt)
# Scrapes a skin until it's fully-scraped
loop do
case DRC.bput("scrape #{hide} with my scraper #{speed}", /^You (quickly|carefully)? scrape your/i, /looks as clean as you/i, /^You scrape your/i)
when /^You (quickly|carefully)? scrape your/i, /^You scrape your/i
waitrt?
next
when /looks as clean as you/
break
else
DRC.message("Unable to scrape leather. Please submit an issue on GitHub: https://github.com/rpherbig/dr-scripts/issues")
DRCI.stow_hands
exit
end
end
DRCC.stow_crafting_item('scraper', @bag, @belt)
end
def apply_preservative(animal, hide, storage, full_preservative)
# This loop applies a single application of preservative unless
# the user has specified "full" application in the args, in which case
# it applies until game messages suggest we're at max.
loop do
# If we have no preservative on-hand, get money,
# get preservative, go back to crafting spot.
unless DRCI.get_item_if_not_held?(@preservative)
DRCM.ensure_copper_on_hand(2000, @settings)
DRCT.order_item(@stock_room, @order_number)
DRCT.walk_to(@room)
end
case DRC.bput("pour #{@preservative} on my #{animal} #{hide}", /^You pour/i, /would only be damaged by adding more/i, /What do you want/i, /^Pour what?/i)
when /^You pour/i
waitrt?
# If user hasn't specified that we apply max preservative, break out
# here after a single application.
break if !full_preservative
next
when /^Pour what?/i
# We've run out of lotion during the pouring process, re-run method, which will buy more
apply_preservative(animal, hide, storage, full_preservative)
when /would only be damaged by adding more/i
break
else
DRC.message("Unable to apply preservative. Please submit an issue on GitHub: https://github.com/rpherbig/dr-scripts/issues")
exit
end
end
unless DRCI.put_away_item?(@preservative, @bag) && DRCI.put_away_item?(hide, storage)
DRC.message("Unable to your store your preservative and/or cleaned hide. Please submit an issue on GitHub: https://github.com/rpherbig/dr-scripts/issues")
DRCI.stow_hands
exit
end
end
end
CleanLeather.new