Sharp Aion2 Lua SDK
Guides

Make a configurable travel helper

Keep your destination in a Lua settings file and request a path on demand.

This module lets you set a map and world position in a separate file. It only requests travel when you press its Go button. Choose coordinates from your own in-game location; the numbers below are placeholders.

Save Scripts/modules/my_travel/settings.lua:

return {
    map_id = 1,
    destination = { x = 100, y = 200, z = 300 },
    arrival_radius = 150,
}

Save Scripts/modules/my_travel/main.lua:

local settings = require("settings")
local ui_sdk = require("ui_sdk")
local traveling = false
local message = "Ready"

local function distance_to_destination(position)
    local destination = settings.destination
    local dx = position.x - destination.x
    local dy = position.y - destination.y
    local dz = position.z - destination.z
    return math.sqrt(dx * dx + dy * dy + dz * dz)
end

local function check_progress()
    local mapId, mapError = game.current_map_id()
    local position, positionError = game.local_position()

    if mapId == nil or position == nil then
        traveling = false
        message = mapError or positionError
    elseif mapId ~= settings.map_id then
        traveling = false
        message = "Map changed"
    elseif distance_to_destination(position) <= settings.arrival_radius then
        traveling = false
        message = "Destination reached"
    end
end

function on_start()
    local ok, err = script.start_worker(function()
        while true do
            if traveling then
                check_progress()
            end
            script.sleep(500)
        end
    end)
    if not ok then log.warn(err) end
end

function on_tick()
    local ok, err = ui_sdk.window("my_travel", "My travel", {
        x = 80, y = 120, width = 300, height = 180,
    }, function(ui)
        ui.text(message)
        if ui.button("go", "Go") then
            local mapId, mapError = game.current_map_id()
            local position, positionError = game.local_position()
            if mapId == nil or position == nil then
                message = mapError or positionError
            elseif mapId ~= settings.map_id then
                message = "Open the configured map first"
            else
                local sent, sendError = game.request_path(
                    settings.destination.x,
                    settings.destination.y,
                    settings.destination.z)
                if sent then
                    traveling = true
                    message = "Path requested"
                else
                    message = sendError
                end
            end
        end
    end)
    if not ok then log.warn(err) end
end

Select the module and press Load. After editing either file, press Reload to import the saved settings again. game.request_path reports whether the request was sent. The position check reports arrival only when your character is within the configured radius; a path request itself does not confirm movement or arrival. Use game.path_destination() to read the current path destination when one is available.