#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/common/api.iss"

variable(global) MRBotApi MRApi

function run_path_action(jsonvalueref params)
{
    variable jsoniterator pathIterator
    params.Get["path"]:GetIterator[pathIterator]

    if !${MRApi(exists)}
    {
        echo "MRApi not available"
        
    }

    if !${MRNav(exists)}
    {
        echo "MRNav not available"
    }

    if ${pathIterator:First(exists)}
    {
        variable point3f nextLocation
        do
        {
            nextLocation:Set[${pathIterator.Value.Get[x]},${pathIterator.Value.Get[y]},${pathIterator.Value.Get[z]}]
            call MRApi.MoveTo "${Me.Name}" "${nextLocation}" 1
            call MRApi.WaitForMoveTo "${Me.Name}" "${nextLocation}" 1
           
        }
        while ${pathIterator:Next(exists)}
    }
}