Last active
April 7, 2019 16:04
-
-
Save yutsuku/35a8b06d6407a76b7abd5dc78e3baa65 to your computer and use it in GitHub Desktop.
World of Warcraft AddOn Plugin for Routes, enables making up routes from TomTom waypoints
This file contains hidden or 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
local Routes = LibStub("AceAddon-3.0"):GetAddon("Routes", 1) | |
if not Routes then return end | |
local SourceName = "TomTom" | |
local L = LibStub("AceLocale-3.0"):GetLocale("Routes") | |
L['Waypoint'] = 'Waypoint' | |
------------------------------------------ | |
-- setup | |
Routes.plugins[SourceName] = {} | |
local source = Routes.plugins[SourceName] | |
do | |
local loaded = true | |
local function IsActive() -- Can we gather data? | |
return TomTom and loaded | |
end | |
source.IsActive = IsActive | |
-- stop loading if the addon is not enabled, or | |
-- stop loading if there is a reason why it can't be loaded ("MISSING" or "DISABLED") | |
local name, title, notes, enabled, loadable, reason, security = GetAddOnInfo(SourceName) | |
if not enabled or (reason ~= nil) then | |
loaded = false | |
return | |
end | |
end | |
------------------------------------------ | |
-- functions | |
local amount_of = {} | |
local function Summarize(data, zone) | |
local continent = Routes.zoneData[zone][3] | |
continent, zone = floor(continent / 100), continent % 100 | |
zone = TomTom:GetMapFile(continent, zone) | |
local node = "Waypoint" | |
local count = #TomTom.waypointprofile[zone] | |
for _, value in ipairs(TomTom.waypointprofile[zone]) do | |
data[ ("%s;%s;%s"):format(SourceName, node, count) ] = ("%s - %d"):format(node, count) | |
end | |
return data | |
end | |
source.Summarize = Summarize | |
local function AppendNodes(node_list, zone, db_type, node_type) | |
local continent = Routes.zoneData[zone][3] | |
continent, zone = floor(continent / 100), continent % 100 | |
zone = TomTom:GetMapFile(continent, zone) | |
local node = "Waypoint" | |
local count = #TomTom.waypointprofile[zone] | |
local coord, title | |
for _, waypoint in ipairs(TomTom.waypointprofile[zone]) do | |
coord, title = waypoint:match("^(%d+):(.*)$") | |
tinsert( node_list, coord ) | |
end | |
return node, node, "Waypoint" | |
end | |
source.AppendNodes = AppendNodes | |
source.AddCallbacks = function() end | |
source.RemoveCallbacks = function() end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment