forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feed-cloak.lic
60 lines (53 loc) · 1.68 KB
/
feed-cloak.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
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#feed-cloak
=end
custom_require.call(%w[common common-travel])
class FeedCloak
include DRC
include DRCT
def initialize
settings = get_settings
@feed_rooms = [settings.feed_cloak_room, settings.safe_room].compact.uniq
main
end
def main
# Try to feed in the current room.
# If unsuccessful then move to designated feed room.
loop do
break if fed_cloak?
room = @feed_rooms.shift
if room && Room.current.id != room
DRCT.walk_to(room)
else
DRC.message("Unable to find a room to feed your cloak. Check your config.")
exit
end
end
end
def fed_cloak?
no_food_in_room = [
/unable to .* nourishment/,
/You shouldn't disturb the silence here/,
/You really shouldn't be loitering in here/,
/but find nothing of interest/,
/Inexplicably, the vines suddenly begin to slither back up your body/
]
not_hungry = /The vines seem uninterested/
done_eating = /They rapidly slither back up around your body/
no_cloak = /What were you referring to?/
cant_feed = /You can't feed/
# Seconds to wait for a message before raise error.
# If a cloak successfully feeds, it may take a variable
# amount of time depending on how hungry it is. A few seconds to minutes.
case DRC.bput("feed my cloak", { 'timeout' => 300 }, *no_food_in_room, not_hungry, done_eating, no_cloak, cant_feed)
when no_cloak, cant_feed
DRC.message("You aren't wearing a cloak that can be fed.")
exit
when *no_food_in_room
false
when not_hungry, done_eating
true
end
end
end
FeedCloak.new