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