Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[route2.lic] v0.4 add go2 custom target support #1751

Merged
merged 7 commits into from
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading