-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/prowadz pokazywanie sciezki (aktualizowana co krok) (#986)
- Loading branch information
Showing
5 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
amap.path_display = amap.path_display or { | ||
highlighter = Highlight:new({}, {255, 200, 150}, {150, 100, 255}) | ||
} | ||
|
||
function amap.path_display:start(destination) | ||
if not tonumber(destination) then | ||
destination = amap.shortcuts:get_room_by_name(destination) | ||
if not destination then | ||
scripts:print_log("Podaj ID lub prawidlowa nazwe skrotu.") | ||
return | ||
end | ||
end | ||
self.destination = tonumber(destination) | ||
|
||
if self.destination == amap.curr.id then | ||
scripts:print_log("Jestes juz na tej lokacji.") | ||
return | ||
end | ||
|
||
self:show_destination() | ||
self.handler = scripts.event_register:force_register_event_handler(self.handler, "amapNewLocation", function() self:show_destination() end) | ||
registerMapInfo("GPS", function() return self:map_info() end) | ||
enableMapInfo("GPS") | ||
if not getPath(amap.curr.id, self.destination) then | ||
scripts:print_log("Aktualnie nie jestem w stanie znalezc sciezki do lokacji " .. destination) | ||
end | ||
end | ||
|
||
|
||
function amap.path_display:stop() | ||
self.highlighter:clear() | ||
scripts.event_register:kill_event_handler(self.handler) | ||
disableMapInfo("GPS") | ||
killMapInfo("GPS") | ||
end | ||
|
||
function amap.path_display:show_destination() | ||
if amap.curr.id == self.destination then | ||
self:stop() | ||
return | ||
end | ||
self.highlighter:clear() | ||
if getPath(amap.curr.id, self.destination) then | ||
self.highlighter:set_locations(speedWalkPath) | ||
self.highlighter:on() | ||
end | ||
end | ||
|
||
function amap.path_display:map_info() | ||
return string.format("Sciezka do %d | Odleglosc: %s", self.destination, #speedWalkPath > 0 and #speedWalkPath or "?"), true | ||
end | ||
|
||
function alias_func_prowadz(id) | ||
amap.path_display:start(id) | ||
end | ||
|
||
function alias_func_prowadz_stop() | ||
amap.path_display:stop() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
amap.walker_highlights = amap.walker_highlights or { | ||
highlighter = Highlight:new({}, {255, 200, 150}, {150, 100, 255}), | ||
event_handlers = {} | ||
} | ||
|
||
function amap.walker_highlights:register_events() | ||
table.insert(self.event_handlers, scripts.event_register:register_event_handler("amapWalkerStarted", function() self:highlight_current_path() end)) | ||
table.insert(self.event_handlers, scripts.event_register:register_event_handler("amapWalkerTerminated", function() self:clear_highlight() end)) | ||
table.insert(self.event_handlers, scripts.event_register:register_event_handler("amapWalkerFinished", function() self:clear_highlight() end)) | ||
self.handler_s = scripts.event_register:force_register_event_handler(self.handler_s, "amapWalkerStarted", function() self:start() end) | ||
self.handler_t = scripts.event_register:force_register_event_handler(self.handler_t, "amapWalkerTerminated", function() self:finish() end) | ||
self.handler_f = scripts.event_register:force_register_event_handler(self.handler_f, "amapWalkerFinished", function() self:finish() end) | ||
end | ||
|
||
function amap.walker_highlights:deregister_events() | ||
for k,v in pairs(self.event_handlers) do | ||
scripts.event_register:kill_event_handler(v) | ||
end | ||
scripts.event_register:kill_event_handler(self.handler_s) | ||
scripts.event_register:kill_event_handler(self.handler_t) | ||
scripts.event_register:kill_event_handler(self.handler_f) | ||
end | ||
|
||
function amap.walker_highlights:highlight_current_path() | ||
self.highlighter:set_locations(speedWalkPath) | ||
self.highlighter:on() | ||
function amap.walker_highlights:start() | ||
amap.path_display:start(speedWalkPath[#speedWalkPath]) | ||
end | ||
|
||
function amap.walker_highlights:clear_highlight() | ||
self.highlighter:clear() | ||
function amap.walker_highlights:finish() | ||
amap.path_display:stop() | ||
end | ||
|
||
amap.walker_highlights:register_events() | ||
|
||
amap.walker_highlights:register_events() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters