LSL Example Pathfinding Wanderer
Revision as of 16:48, 21 February 2017 by Caleb Linden (talk | contribs)
This is a pathfinding test script, which is a simple wandering character.
// wandering box; touch me to start wandering default { on_rez(integer reznum) { llResetScript(); } state_entry() { llSay(0, "Touch me to trigger wandering"); llDeleteCharacter(); llCreateCharacter([]); } touch_start(integer detected) { llWanderWithin(llGetPos(), <20.0, 20.0, 5.0>, []); } path_update(integer type, list reserved) { string update_desc; if (type == PU_SLOWDOWN_DISTANCE_REACHED) { update_desc = "Near"; } else if (type == PU_GOAL_REACHED) { update_desc = "Stopping"; } else if (type == PU_FAILURE_INVALID_START) { update_desc = "Cannot path find from current location!"; } else if (type == PU_FAILURE_INVALID_GOAL) { update_desc = "Goal not on navmesh!"; } else if (type == PU_FAILURE_UNREACHABLE) { update_desc = "Goal unreachable!"; } else if (type == PU_FAILURE_TARGET_GONE) { update_desc = "Target gone!"; } else if (type == PU_FAILURE_NO_VALID_DESTINATION) { update_desc = "No place to go!"; } else if (type == PU_EVADE_HIDDEN) { update_desc = "I am hidden from my pursuer"; } else if (type == PU_EVADE_SPOTTED) { update_desc = "I was found by my pursuer"; } else if (type == PU_FAILURE_NO_NAVMESH) { update_desc = "Error: there is no navmesh for this region?!"; } else if(type == PU_FAILURE_DYNAMIC_PATHFINDING_DISABLED) { update_desc = "Dynamic pathfinding is disabled in this region"; } else if(type == PU_FAILURE_PARCEL_UNREACHABLE) { update_desc = "Failed to enter a parcel - is it full?"; } else { update_desc = "Erm... Not a known value!"; } llOwnerSay("path_update: " + (string)type + ": " + update_desc); } }