Add new code snippets
This commit is contained in:
51
Random Trash/TomTom/2.lua
Normal file
51
Random Trash/TomTom/2.lua
Normal file
@@ -0,0 +1,51 @@
|
||||
-- TODO: Make this not suck
|
||||
function TomTom:AddWaypoint(x, y, desc, persistent, minimap, world, silent)
|
||||
local c,z = GetCurrentMapContinent(), GetCurrentMapZone()
|
||||
|
||||
if not c or not z or c < 1 then
|
||||
--self:Print("Cannot find a valid zone to place the coordinates")
|
||||
return
|
||||
end
|
||||
|
||||
return self:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, nil, silent)
|
||||
end
|
||||
|
||||
function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, callbacks, silent, crazy)
|
||||
-- Convert the c,z,x,y tuple to m,f,x,y and pass the work off to AddMFWaypoint()
|
||||
local mapId, floor = hbd:GetMapIDFromCZ(c, z)
|
||||
if not mapId then
|
||||
return
|
||||
end
|
||||
|
||||
return self:AddMFWaypoint(mapId, floor, x/100, y/100, {
|
||||
title = desc,
|
||||
persistent = persistent,
|
||||
minimap = minimap,
|
||||
world = world,
|
||||
callbacks = callbacks,
|
||||
silent = silent,
|
||||
crazy = crazy,
|
||||
})
|
||||
end
|
||||
|
||||
function TomTom:AddWaypointToCurrentZone(x, y, desc)
|
||||
local m, f = TomTom:GetCurrentPlayerPosition()
|
||||
if not m then
|
||||
return
|
||||
end
|
||||
|
||||
return self:AddMFWaypoint(m, f, x/100, y/100, {
|
||||
title = desc,
|
||||
})
|
||||
end
|
||||
|
||||
function TomTom:SetCustomWaypoint(c,z,x,y,callback,minimap,world,silent)
|
||||
return self:AddZWaypoint(c, z, x, y, nil, false, minimap, world, callback, silent)
|
||||
end
|
||||
|
||||
|
||||
function TomTom:SetCustomMFWaypoint(m, f, x, y, opts)
|
||||
opts.persistent = false
|
||||
|
||||
return self:AddMFWaypoint(m, f, x, y, opts)
|
||||
end
|
||||
68
Random Trash/TomTom/3.lua
Normal file
68
Random Trash/TomTom/3.lua
Normal file
@@ -0,0 +1,68 @@
|
||||
function TomTom:AddMFWaypoint(m, f, x, y, opts)
|
||||
opts = opts or {}
|
||||
|
||||
-- Default values
|
||||
if opts.persistent == nil then opts.persistent = self.profile.persistence.savewaypoints end
|
||||
if opts.minimap == nil then opts.minimap = self.profile.minimap.enable end
|
||||
if opts.world == nil then opts.world = self.profile.worldmap.enable end
|
||||
if opts.crazy == nil then opts.crazy = self.profile.arrow.autoqueue end
|
||||
if opts.cleardistance == nil then opts.cleardistance = self.profile.persistence.cleardistance end
|
||||
if opts.arrivaldistance == nil then opts.arrivaldistance = self.profile.arrow.arrival end
|
||||
|
||||
if not opts.callbacks then
|
||||
opts.callbacks = TomTom:DefaultCallbacks(opts)
|
||||
end
|
||||
|
||||
local zoneName = hbd:GetLocalizedMap(m)
|
||||
|
||||
-- Get the default map floor, if necessary
|
||||
if not f then
|
||||
local floors = hbd:GetNumFloors(m)
|
||||
f = floors == 0 and 0 or 1
|
||||
end
|
||||
|
||||
-- Ensure there isn't already a waypoint at this location
|
||||
local key = self:GetKey({m, f, x, y, title = opts.title})
|
||||
if waypoints[m] and waypoints[m][key] then
|
||||
return waypoints[m][key]
|
||||
end
|
||||
|
||||
-- uid is the 'new waypoint' called this for historical reasons
|
||||
local uid = {m, f, x, y, title = opts.title}
|
||||
|
||||
-- Copy over any options, so we have em
|
||||
for k,v in pairs(opts) do
|
||||
if not uid[k] then
|
||||
uid[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
-- No need to convert x and y because they're already 0-1 instead of 0-100
|
||||
self:SetWaypoint(uid, opts.callbacks, opts.minimap, opts.world)
|
||||
if opts.crazy then
|
||||
self:SetCrazyArrow(uid, opts.arrivaldistance, opts.title)
|
||||
end
|
||||
|
||||
waypoints[m] = waypoints[m] or {}
|
||||
waypoints[m][key] = uid
|
||||
|
||||
-- If this is a persistent waypoint, then add it to the waypoints table
|
||||
if opts.persistent then
|
||||
self.waypointprofile[m][key] = uid
|
||||
end
|
||||
|
||||
if not opts.silent and self.profile.general.announce then
|
||||
local ctxt = RoundCoords(x, y, 2)
|
||||
local desc = opts.title and opts.title or ""
|
||||
local sep = opts.title and " - " or ""
|
||||
local msg = string.format(L["|cffffff78TomTom:|r Added a waypoint (%s%s%s) in %s"], desc, sep, ctxt, zoneName)
|
||||
ChatFrame1:AddMessage(msg)
|
||||
end
|
||||
return uid
|
||||
end
|
||||
|
||||
local coord_fmt = "%%.%df, %%.%df"
|
||||
function RoundCoords(x,y,prec)
|
||||
local fmt = coord_fmt:format(prec, prec)
|
||||
return fmt:format(x*100, y*100)
|
||||
end
|
||||
1411
Random Trash/TomTom/TomTom.lua
Normal file
1411
Random Trash/TomTom/TomTom.lua
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user