-
Notifications
You must be signed in to change notification settings - Fork 3
/
route2.lic
147 lines (121 loc) · 3.12 KB
/
route2.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
=begin
Shows the route between your current room and the target room, or between two target rooms.
Intended for troubleshooting mapDB issues
author: LostRanger ([email protected])
game: any
tags: utility
required: Lich >= 4.6.0.
version: 0.2
changelog:
version 0.2 (2020-03-04)
* Cleanup output to be more friendly and useable.
* Actually add polish for release-quality scripts
* Should now work with tags in addition to room numbers and descriptions.
version 0.1 (2020-03-04)
* First public release
=end
def find_room(what, src=nil)
if what =~ /^\d+$/
rm = Room[what]
return rm if rm
echo "Room ##{what} does not exist."
exit
end
src ||= Room.current
rm = src.find_nearest_by_tag(what)
if rm
rm = Room[rm]
echo "Nearest room tagged '#{what}' is room ##{rm.id}"
return rm
end
rm = Room[what]
if rm
echo "First room matching '#{what}' is room ##{rm.id}"
return rm
end
echo "Could not find room '#{what}'"
echo "Usage: #{$lich_char}#{Script.current.name} [source] target"
exit
end
if script.vars[2]
src = find_room(script.vars[1])
tgt = find_room(script.vars[2], src)
elsif script.vars[1]
src = Room.current
unless src
echo "Could not identify your current room."
echo "Usage: #{$lich_char}#{script.name} [source] target"
exit
end
tgt = find_room(script.vars[1])
else
echo "Usage: #{$lich_char}#{script.name} [source] target"
exit
end
# unless src
# echo "Source room not found."
# exit
# end
#
# unless tgt
# echo "Target room not found."
# exit
# end
if src.id == tgt.id
echo "Source and target rooms match."
exit
end
path = src.path_to(tgt)
unless path
echo "Path from #{src.id} to #{tgt.id} not found"
exit
end
path << tgt.id
total_time = 0
step = 0
time_mod = 0
msg = []
rm = src
msg << " STEP TRIP TIME MOVE ROOM NAME"
msg << "----- ---------- ------ ------------------------------ ------- -------------------------------"
sid = "##{src.id}".rjust(7)
msg << " 0: #{sid} #{src.title[0]}"
path.each do |id|
id = id.to_s
sid = "##{id}".rjust(7)
wayto = rm.wayto[id]
wayto = "(StringProc)" if wayto.is_a?(StringProc)
if wayto.length > 30
wayto = wayto[0..27] + "..."
end
wayto = wayto.ljust(30)
timeto = rm.timeto[id]
rm = Room[id]
title = rm.title[0]
step += 1
if timeto.nil?
stime = "<NIL>"
time_mod |= 1
elsif timeto.is_a?(StringProc)
stime = "(proc)"
time_mod |= 2
else
total_time += timeto
stime = timeto.round(1).to_s
end
sstep = step.to_s.rjust(4)
stime = stime.rjust(6)
sttime = total_time.round(1).to_s.rjust(8)
case time_mod
when 1
sttime += "+? "
when 2
sttime += "+P "
when 3
sttime += "+P?"
else
sttime += " "
end
msg << "#{sstep}: #{sttime} #{stime} #{wayto} #{sid} #{title}"
end
respond msg