# path_update

*LSL event*

```lsl
path_update(integer type, list reserved)
```

- `integer type`: Path update status or failure code constant (PU_* flag).
- `list reserved`: Reserved parameter (currently unused).

Triggered to inform the script of changes or failures in the pathfinding character's status.

Event description goes here.

```lsl title="How to use" frame="terminal"
path_update(integer type, list reserved)
{

}
```

## Specification

| Constant | Type | Value | Description |
| --- | --- | --- | --- |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_SLOWDOWN_DISTANCE_REACHED | `integer` | Character is near current goal. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_GOAL_REACHED | `integer` | Character has reached the goal and will stop or choose a new goal (if wandering). |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_INVALID_START | `integer` | Character cannot navigate from the current location - e.g., the character is off the navmesh or too high above it. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_INVALID_GOAL | `integer` | Goal is not on the navmesh and cannot be reached. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_UNREACHABLE | `integer` | Goal is no longer reachable for some reason - e.g., an obstacle blocks the path. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_TARGET_GONE | `integer` | Target (for llPursue or llEvade) can no longer be tracked - e.g., it left the region or is an avatar that is now more than about 30m outside the region. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_NO_VALID_DESTINATION | `integer` | There's no good place for the character to go - e.g., it is patrolling and all the patrol points are now unreachable. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_EVADE_HIDDEN | `integer` | Triggered when an llEvade character thinks it has hidden from its pursuer. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_EVADE_SPOTTED | `integer` | Triggered when an llEvade character switches from hiding to running |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_NO_NAVMESH | `integer` | This is a fatal error reported to a character when there is no navmesh for the region. This usually indicates a server failure and users should file a bug report and include the time and region in which they received this message. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_DYNAMIC_PATHFINDING_DISABLED | `integer` | Triggered when a character enters a region with dynamic pathfinding disabled.  Dynamic pathfinding can be toggled by estate managers via the 'dynamic_pathfinding' option in the Region Debug Console. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_PARCEL_UNREACHABLE | `integer` | Triggered when a character failed to enter a parcel because it is not allowed to enter, e.g. because the parcel is already full or because object entry was disabled after the navmesh was baked. |
| [m=3](https://wiki.secondlife.com/wiki/m%3D3) | PU_FAILURE_OTHER | `integer` | Other failure. |

<table>
	<tr>
		<th>Constants</th>
		<th>Value</th>
		<th>Description</th>
	</tr>
</table>

## Caveats

- Note that if wandering, the "stop" (`PU_GOAL_REACHED`) type may never occur as a new goal may be chosen when near (`PU_SLOWDOWN_DISTANCE_REACHED`) the previous goal.
- When the character cannot navigate from the current position (`PU_FAILURE_INVALID_START`) [llNavigateTo](/functions/llNavigateTo/) with the `FORCE_DIRECT_PATH` option may be helpful.

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-68}
create_wandering_character()
{
//  Clear any previous character behaviors
    llDeleteCharacter();

//  MAX_SPEED is @ 20 by default
    llCreateCharacter([
        CHARACTER_MAX_SPEED, 25.0,
        CHARACTER_DESIRED_SPEED, 15.0]);

    llWanderWithin(llGetPos(), <10.0, 10.0,  2.0>, []);
}

list get_pathupdate_failure_info(integer type)
{
    if (type == PU_SLOWDOWN_DISTANCE_REACHED)
        return ["Near", FALSE];

    if (type == PU_GOAL_REACHED)
        return ["Stopping", FALSE];

    if (type == PU_FAILURE_INVALID_START)
        return ["Cannot path find from current location! Attempting "
                + "to go to the center of the region.", TRUE];

    if (type == PU_FAILURE_INVALID_GOAL)
        return ["Goal not on navmesh!", FALSE];

    if (type == PU_FAILURE_UNREACHABLE)
        return ["Goal unreachable!", FALSE];

    if (type == PU_FAILURE_TARGET_GONE)
        return ["Target gone!", FALSE];

    if (type == PU_FAILURE_NO_VALID_DESTINATION)
        return ["No place to go!", FALSE];

    if (type ==  PU_EVADE_HIDDEN)
        return ["Hiding from pursuer...", FALSE];

    if (type == PU_EVADE_SPOTTED)
        return ["Switched from hiding to running...", FALSE];

    if (type ==  PU_FAILURE_NO_NAVMESH)
        return ["Region has no nav mesh..", FALSE];

    if (type == PU_FAILURE_DYNAMIC_PATHFINDING_DISABLED)
        return ["Dynamic pathfinding is disabled in this region.", FALSE];

    if (type == PU_FAILURE_PARCEL_UNREACHABLE)
        return ["Parcel entry problem (is the parcel full?).", FALSE];

    if (type == PU_FAILURE_OTHER)
        return ["Hit an unspecified failure", FALSE];

    return ["Unknown failure", FALSE];
}

default
{
    on_rez(integer start_param)
    {
        llResetScript();
    }

    state_entry()
    {
        create_wandering_character();
    }

    path_update(integer type, list reserved)
    {
        list params = get_pathupdate_failure_info(type);
        string info = llList2String(params, 0);
        integer /* boolean */ hasToMove = llList2Integer(params, 1);

        llRegionSayTo(llGetOwner(), 0, info);
        if (hasToMove)
        {
            vector currentPosition = llGetPos();
            llNavigateTo(<128.0, 128.0, llGround(<128.0, 128.0, 0.0> - currentPosition)>, [FORCE_DIRECT_PATH, TRUE]);
        }
    }
}
```

</details>

## History

Date of Release [31/07/2012](https://wiki.secondlife.com/wiki/Release_Notes/Second_Life_Server/12#12-07-31-262785)

## See also

### Functions

- [llCreateCharacter](/functions/llCreateCharacter/)
- [llDeleteCharacter](/functions/llDeleteCharacter/)
- [llEvade](/functions/llEvade/)
- [llExecCharacterCmd](/functions/llExecCharacterCmd/)
- [llGetClosestNavPoint](/functions/llGetClosestNavPoint/)
- [llFleeFrom](/functions/llFleeFrom/)
- [llNavigateTo](/functions/llNavigateTo/)
- [llPatrolPoints](/functions/llPatrolPoints/)
- [llPursue](/functions/llPursue/)
- [llUpdateCharacter](/functions/llUpdateCharacter/)
- [llWanderWithin](/functions/llWanderWithin/)

---

*Source: [Path update](https://wiki.secondlife.com/wiki/Path_update) on the Second Life Wiki. Content from the Second Life Wiki articles Path update (revision 1217461, 2024-10-06) and Template:LSL Constants/path update (revision 1215211, 2023-10-28), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/events/path_update/
