Quantcast

Add a method to get a table of default callbacks

Author James Whitehead II <jnwhiteh@gmail.com>
Author date 2012-10-08 06:20:30
Author local date 2012-10-08 08:20:30 +0200
Committer James Whitehead II <jnwhiteh@gmail.com>
Committer date 2012-10-08 06:20:30
Committer local date 2012-10-08 08:20:30 +0200
Commit 6d0bf72ba6d96d31064c3f21cce52f6db2e88130
Tree 7c4e6404e165d5bd855a98eac046f924384b13ed
Parent b49ef063c0aed1b5a822ef9188a0e570321109b4
Add a method to get a table of default callbacks

This makes it possible for an add-on to create a waypoint with custom callbacks without losing the tooltip/onclick functionality that currently exists in TomTom. Usage is something like this:

local opts = {} -- any options for your waypoint, such as title, etc.
opts.callbacks = TomTom:DefaultCallbacks()
opts.callbacks.distance[15] = function(event, uid, range, distance, lastdistance)
  -- this function will be called when the player moves from
  -- outside 15 yards to within, or vide-versa and passed
  -- several parameters
  --
  -- event: "distance"
  -- uid: the UID of the waypoint
  -- range: the callback range being triggered (15 in this case)
  -- distance: the current distance to the waypoint
  --           this MAY be less than 15, if you move really fast
  -- lastdistance: the previous distance to the waypoint. This
  --               can be used to determine whether or not you are
  --               leaving the circle or entering it.

  if not lastdistance or lastdistance and lastdistance > dist then
    -- entering circle
  else
    -- exiting circle
  end
end