Watch a walk: progress and events
Log what a walk does on the way: its route, its progress, stucks, the server. Useful for a status line, or to find out why a walk is slow.
local self = {}
local client = _G.AXIOM_NAV and _G.AXIOM_NAV.client
if not client then return end
client:on("path_received", function(d)
local route = client:get_route()
core.log(("route in: %d points"):format(route and #route or 0))
end, self)
client:on("stuck_detected", function() core.log("stuck, getting free") end, self)
client:on("stuck_recovered", function() core.log("free again") end, self)
client:on("deviation_detected", function() core.log("pushed off the route") end, self)
client:on("server_disconnected", function() core.log_warning("route server not answering") end, self)
client:on("state_changed", function(d)
core.log(("state: %s.%s -> %s.%s"):format(
tostring(d.from), tostring(d.substate_from), tostring(d.to), tostring(d.substate_to)))
end, self)
-- a status line, once a second
local last = 0
core.register_on_update_callback(function()
if core.time() - last < 1000 then return end
last = core.time()
if not client:is_moving() then return end
local p = client:get_progress()
core.log(("%s, %.0f%%, %d points left"):format(client:get_state_detail(), p.percent or 0, p.waypoints_remaining or 0))
end)
-- when you are done watching
-- client:off(self)What the states mean
| State | Meaning |
|---|---|
navigating.awaiting_path | Waiting for the route server |
navigating.following_path | Walking (also while waiting at a mount point or on a pad) |
navigating.repathing | A new route on the way |
navigating.recovering.* | Getting unstuck: jumping, probing, strafing, backtracking |
navigating.deferred | Waiting for a cast to end |