Difference between revisions of "Path update debugging"

From Second Life Wiki
Jump to: navigation, search
(Created page with "It require 4 objects to work with this script. Name one prim "Red", another prim named "Green" and another as "Blue". These colored prim are used for tracking them. One more pri…")
 
m (change out TYPE variable to avoid keyword)
 
Line 49: Line 49:
 
     }
 
     }
  
     path_update(integer type, list reserved){
+
     path_update(integer typeUpdate, list reserved){
             if (type == PU_SLOWDOWN_DISTANCE_REACHED  ){ llOwnerSay("Slowdown: Near Goal");              }
+
             if (typeUpdate == PU_SLOWDOWN_DISTANCE_REACHED  ){ llOwnerSay("Slowdown: Near Goal");              }
         else if (type == PU_GOAL_REACHED                ){ llOwnerSay("Goal: Reached");                    }
+
         else if (typeUpdate == PU_GOAL_REACHED                ){ llOwnerSay("Goal: Reached");                    }
         else if (type == PU_FAILURE_INVALID_START      ){ llOwnerSay("Failure: Not connected to NavMesh"); }
+
         else if (typeUpdate == PU_FAILURE_INVALID_START      ){ llOwnerSay("Failure: Not connected to NavMesh"); }
         else if (type == PU_FAILURE_INVALID_GOAL        ){ llOwnerSay("Failure: Goal not on NavMesh");      }
+
         else if (typeUpdate == PU_FAILURE_INVALID_GOAL        ){ llOwnerSay("Failure: Goal not on NavMesh");      }
         else if (type == PU_FAILURE_UNREACHABLE        ){ llOwnerSay("Failure: Unreachable");              }
+
         else if (typeUpdate == PU_FAILURE_UNREACHABLE        ){ llOwnerSay("Failure: Unreachable");              }
         else if (type == PU_FAILURE_TARGET_GONE        ){ llOwnerSay("Failure: Target Missing");          }
+
         else if (typeUpdate == PU_FAILURE_TARGET_GONE        ){ llOwnerSay("Failure: Target Missing");          }
         else if (type == PU_FAILURE_NO_VALID_DESTINATION){ llOwnerSay("Failure: No Valid Destination");    }
+
         else if (typeUpdate == PU_FAILURE_NO_VALID_DESTINATION){ llOwnerSay("Failure: No Valid Destination");    }
         else if (type == PU_EVADE_HIDDEN                ){ llOwnerSay("Evade: Hidden");                    }
+
         else if (typeUpdate == PU_EVADE_HIDDEN                ){ llOwnerSay("Evade: Hidden");                    }
         else if (type == PU_EVADE_SPOTTED              ){ llOwnerSay("Evade: Spotted");                    }
+
         else if (typeUpdate == PU_EVADE_SPOTTED              ){ llOwnerSay("Evade: Spotted");                    }
         else if (type == PU_FAILURE_NO_NAVMESH          ){ llOwnerSay("Failure: No NavMesh");              }
+
         else if (typeUpdate == PU_FAILURE_NO_NAVMESH          ){ llOwnerSay("Failure: No NavMesh");              }
         else if (type == PU_FAILURE_OTHER              ){ llOwnerSay("Failure: Other");                    }
+
         else if (typeUpdate == PU_FAILURE_OTHER              ){ llOwnerSay("Failure: Other");                    }
  
 
         else{  llOwnerSay("Unknown failure"); }
 
         else{  llOwnerSay("Unknown failure"); }
 
     }
 
     }
 
}
 
}

Latest revision as of 10:37, 10 August 2012

It require 4 objects to work with this script. Name one prim "Red", another prim named "Green" and another as "Blue". These colored prim are used for tracking them.

One more prim named "hot" but is 2m x 2m x 0.1m cylinder to test it's avoiding range. place hot prim inside the a prim with the script, for rezzing.

It has listen command to do your bidding, useful for testing command conflicts.


<lsl>

key Green; key Blue; key Red;

vector PosTarget(key ID){

   return (llList2Vector(llGetObjectDetails(ID, [3]),0));

}


default {

   state_entry(){
       llCreateCharacter([CHARACTER_DESIRED_SPEED, 5.0]);
       llListen( 0, "", "", "");
       llSensor("","",(PASSIVE | ACTIVE ),96,PI);
   }
   
   sensor(integer Num){
       integer aNum;
       for (aNum=0; aNum<Num; aNum++){
           string Tar = llDetectedName(aNum);
           if (Tar == "Green"){Green=llDetectedKey(aNum);  llOwnerSay("Green found");}
           if (Tar == "Blue"){Blue=llDetectedKey(aNum);    llOwnerSay("Blue found");}
           if (Tar == "Red"){Red=llDetectedKey(aNum);      llOwnerSay("Red found");}
       }
   }
   listen( integer ch, string n, key id, string m ){
            if(m=="jump"){ llExecCharacterCmd( 1, [2.0] ); }
       else if(m=="stop"){ llExecCharacterCmd( 0, [] ); }
       else if(m=="wander"){ llWanderWithin( llGetPos(), 300.0, []); }
       else if(m=="evade"){ llEvade( Red, []); }
       else if(m=="chase"){ llPursue( Blue, []); }
       else if(m=="follow"){ llPursue( id, []); }
       else if(m=="hot"){ llFleeFrom( llGetPos(), 3, []); llRezObject( "hot", llGetPos(), <0,0,0>,<0,0,0,0>,0);}
       else if(m=="here"){ llNavigateTo( PosTarget(id), [FORCE_DIRECT_PATH, 0]); }
       else if(m=="now"){ llNavigateTo( PosTarget(id), [FORCE_DIRECT_PATH, 1]); }
       else if(m=="close"){ llGetClosestNavPoint( PosTarget(Green), []); }
   }
   path_update(integer typeUpdate, list reserved){
            if (typeUpdate == PU_SLOWDOWN_DISTANCE_REACHED   ){ llOwnerSay("Slowdown: Near Goal");               }
       else if (typeUpdate == PU_GOAL_REACHED                ){ llOwnerSay("Goal: Reached");                     }
       else if (typeUpdate == PU_FAILURE_INVALID_START       ){ llOwnerSay("Failure: Not connected to NavMesh"); }
       else if (typeUpdate == PU_FAILURE_INVALID_GOAL        ){ llOwnerSay("Failure: Goal not on NavMesh");      }
       else if (typeUpdate == PU_FAILURE_UNREACHABLE         ){ llOwnerSay("Failure: Unreachable");              }
       else if (typeUpdate == PU_FAILURE_TARGET_GONE         ){ llOwnerSay("Failure: Target Missing");           }
       else if (typeUpdate == PU_FAILURE_NO_VALID_DESTINATION){ llOwnerSay("Failure: No Valid Destination");     }
       else if (typeUpdate == PU_EVADE_HIDDEN                ){ llOwnerSay("Evade: Hidden");                     }
       else if (typeUpdate == PU_EVADE_SPOTTED               ){ llOwnerSay("Evade: Spotted");                    }
       else if (typeUpdate == PU_FAILURE_NO_NAVMESH          ){ llOwnerSay("Failure: No NavMesh");               }
       else if (typeUpdate == PU_FAILURE_OTHER               ){ llOwnerSay("Failure: Other");                    }
       else{   llOwnerSay("Unknown failure"); }
   }

}