Skip to content

Commit

Permalink
Merge pull request #1751 from elanthia-online/route2-v0.4
Browse files Browse the repository at this point in the history
[route2.lic] v0.4 add go2 custom target support
  • Loading branch information
mrhoribu authored Jan 19, 2025
2 parents c7816ed + 70d787a commit 5608082
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions scripts/route2.lic
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
tags: utility
required: Lich >= 5.6.2
version: 0.3
version: 0.4
changelog:
version 0.4 (2025-01-19)
* Add support for route2 a custom go2 target
* Remove location column if not GS4
version 0.3 (2024-09-03)
* Change output to use terminal-table
Expand All @@ -33,8 +37,26 @@ def find_room(what, src = nil)
echo "Room ##{what} does not exist."
exit
end

src ||= Room.current

if defined?(DB_Store)
if (custom_targets = DB_Store.read("#{XMLData.game}", 'go2')["custom targets"]) && ((target = custom_targets.keys.find { |key| key =~ /^#{what}$/i }) or (target = custom_targets.keys.find { |key| key =~ /^#{what}/i }))
unless custom_targets[target].kind_of?(Array)
echo("Custom targets is an integer: #{custom_targets[target].kind_of?(Integer)}")
destination_id = custom_targets[target]
else
echo("Custom targets is an array: #{custom_targets[target].kind_of?(Array)}")
destination_id = Room.current.find_nearest(custom_targets[target].uniq)
end
unless Map[destination_id]
echo "error: custom target (#{destination_id}) was not found in the map database"
else
echo "First closest matching custom target '#{what}' is room ##{destination_id}"
return Map[destination_id]
end
end
end

rm = src.find_nearest_by_tag(what)
if rm
rm = Room[rm]
Expand Down Expand Up @@ -96,10 +118,17 @@ step = 0
time_mod = 0
rm = src

headers = %i[STEP TRIP TIME MOVE ROOM NAME LOCATION]
if XMLData.game =~ /^GS/
headers = %i[STEP TRIP TIME MOVE ROOM NAME LOCATION]
else
headers = %i[STEP TRIP TIME MOVE ROOM NAME]
end
table_rows = []
table_rows.push(["#{0.to_s.rjust(4)}:", '', '', '', src.id, src.title[0], src.location])

if XMLData.game =~ /^GS/
table_rows.push(["#{0.to_s.rjust(4)}:", '', '', '', src.id, src.title[0], src.location])
else
table_rows.push(["#{0.to_s.rjust(4)}:", '', '', '', src.id, src.title[0]])
end
path.each do |id|
id = id.to_s
"##{id}".rjust(7)
Expand Down Expand Up @@ -140,7 +169,11 @@ path.each do |id|
else
sttime += " "
end
table_rows.push(["#{sstep}:", sttime, stime, wayto, id, title, location])
if XMLData.game =~ /^GS/
table_rows.push(["#{sstep}:", sttime, stime, wayto, id, title, location])
else
table_rows.push(["#{sstep}:", sttime, stime, wayto, id, title])
end
end
table = Terminal::Table.new(
headings: headers,
Expand Down

0 comments on commit 5608082

Please sign in to comment.