Project Sylvanas docs axiombot.net Discord

Plugin skeleton: a patrol

A whole plugin, ready to copy: it walks a list of points in a loop, and retries a point that failed. It shows the three things every AXIOM NAV plugin needs:

  1. Load after AXIOM NAV (init_priority 3 or higher).
  2. Look the client up when you need it, not at file load.
  3. One walk at a time: send the next only from the last one's done.
local plugin = {}
plugin["name"] = "Patrol Example"
plugin["version"] = "1.0"
plugin["author"] = "You"
plugin["init_priority"] = 3   -- after AXIOM_NAV (2)
plugin["load"] = true

local me = core.object_manager.get_local_player()
if not me or not me:is_valid() then
    plugin["load"] = false
end
return plugin
local POINTS = {
    { x = -8913.2, y = -134.6, z = 80.5 },
    { x = -8851.0, y = -190.3, z = 81.9 },
    { x = -8790.4, y = -120.8, z = 83.1 },
}
local RETRY_MS = 3000

local self = {}          -- our owner for listeners
local index = 1
local walking = false
local wait_until = 0

local function nav()
    local api = _G.AXIOM_NAV
    return api and api.client
end

local function walk_next(client)
    walking = true
    client:move_to(POINTS[index], function(ok, reason, detail)
        walking = false
        if ok then
            index = index % #POINTS + 1                 -- next point, back to 1 after the last
        else
            core.log_warning(("patrol: point %d failed: %s"):format(index, tostring(detail and detail.detail or reason)))
            if reason == "unreachable" then
                index = index % #POINTS + 1             -- skip it
            end
            wait_until = core.time() + RETRY_MS         -- breathe before the next try
        end
    end, { avoid_mobs = true })
end

core.register_on_update_callback(function()
    local client = nav()
    if not client or walking or core.time() < wait_until then return end
    walk_next(client)
end)

Notes

  • walking makes sure only one walk is sent at a time. move_to is safe to call often, but waiting for done is clearer.
  • To stop the patrol from your own toggle: client:stop(), then client:off(self) if you added listeners.
  • If AXIOM NAV is not installed, nav() stays nil and the plugin does nothing.