Skip to content

Commit

Permalink
[route2.lic] v0.4 add go2 custom target support
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhoribu authored Jan 19, 2025
1 parent c7816ed commit 8cafa6f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions scripts/route2.lic
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
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
version 0.3 (2024-09-03)
* Change output to use terminal-table
Expand All @@ -33,8 +36,24 @@ def find_room(what, src = nil)
echo "Room ##{what} does not exist."
exit
end

src ||= Room.current

unless defined?(DB_Store)
if (custom_targets = DB_Store.read("GSF", '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 (destination = Map[destination_id])
echo "error: custom target (#{destination_id}) was not found in the map database"
end
echo "nearest room for custom target: #{target} is #{destination_id} #{Map[destination_id].title.first}"
end
end

rm = src.find_nearest_by_tag(what)
if rm
rm = Room[rm]
Expand Down

0 comments on commit 8cafa6f

Please sign in to comment.