Navigation with a Timeout
Use asynchronous navigation when Lua needs to monitor a deadline or other game state while Hexis moves.
local function navigate_with_timeout(target, timeout)
hexis.timer.start()
if not hexis.navigate.start_async(target) then
return false, "navigation_not_started"
end
while hexis.navigate.is_navigating() do
if not hexis.script.is_running() then
hexis.navigate.stop()
return false, "script_stopped"
end
if hexis.timer.elapsed() >= timeout then
hexis.navigate.stop()
return false, "timeout"
end
hexis.wait(0.1)
end
return true, "completed"
end
function hexis.main()
local ok, reason = navigate_with_timeout({
x = 100,
y = 64,
z = 200,
distance = 2
}, 30)
if ok then
hexis.log.info("Navigation completed")
else
hexis.log.warn("Navigation stopped: " .. reason)
end
end
start_async() reports whether Hexis accepted the request. Completion,
deadline expiry, and script cancellation remain separate outcomes in Lua.