|
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
|
03-27-2007 03:04
Im currently scripting a basic guarddog, its using a sensor but its not moving to the next state somehow... the script has 4 states - default - patrol - attack - retreat Somehow the sensor doenst seem to do the trick :/ I cant get it to go to the next (attack) state, but it doesnt say "target found" either...
functie_sensor() { llSensorRepeat("",llGetOwner(),AGENT,200,2*PI,0.5); }
state patrol { state_entry() { llSay(0,"State Patrol"); functie_sensor(); functie_startup(); functie_patrol(); }
sensor(integer total_number) { llSay(0,"TARGET FOUND!"); llStopMoveToTarget(); state attack; } }
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
03-27-2007 04:18
With the script this butchered it's impossible to say what's wrong with your script. The snippets you've left, whilst not perfect and obviously uncompilable, should ping if you are within 96m of your dog and in the same sim.
Although your llSensorRepeat will fire a 0.5s repeat time won't make you popular as it will chew sim resources. Also max range for a sensor in 96m, and PI not TWO_PI or (2 * PI) will give you full coverage.
try llSensorRepeat("", llGetOwner(), AGENT, 96.0, PI, 0.5); (assuming you want to stick to the fast time). It won't change the actual functioning, but will save you a little memory.
|
|
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
|
03-27-2007 04:41
thanks for the help. i read somewhere that a single prim cant have multiple sensors.
But is it possible to have multiple sensors in a single script but in different states?
|
|
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
|
03-27-2007 04:51
vector home;// = <550,119,74>; vector current_position; vector offset = <2,0,0>;
vector destination1; vector destination2; vector destination3; vector destination4; vector destination5; vector destination6; vector destination7; vector destination8; key id;// = llGetOwner();
functie_sensor() { llSensorRepeat("",NULL_KEY,AGENT,200,2*PI,0.5); }
functie_startup() // PROPERTIES { llSay(0,"STARTUP"); llStopSound(); llSetHoverHeight(0.5, 0, 1); llSetStatus(STATUS_ROTATE_Z, TRUE); llSetStatus(STATUS_ROTATE_X, FALSE); llSetStatus(STATUS_ROTATE_Y, FALSE); llSetStatus(STATUS_PHYSICS, TRUE); llSetRot(<0,0,0,1>); key id = llGetOwner(); }
functie_pause() { llSleep(1.7); }
functie_patrol() { llOwnerSay((string)home); //functie_pause(); llLookAt(destination1, .1, 1); llMoveToTarget(destination1, 2); functie_pause(); llLookAt(destination2, .1, 1); llMoveToTarget(destination2, 2); functie_pause(); llLookAt(destination3, .1 ,1); llMoveToTarget(destination3, 2); functie_pause(); llLookAt(destination4, .1 ,1); llMoveToTarget(destination4, 2); functie_pause(); llLookAt(destination5, .1, 1); llMoveToTarget(destination5, 2); functie_pause(); llLookAt(destination6, .1, 1); llMoveToTarget(destination6, 2); functie_pause(); llLookAt(destination7, .1 ,1); llMoveToTarget(destination7, 2); functie_pause(); llLookAt(destination8, .1 ,1); llMoveToTarget(destination8, 2); functie_pause();
functie_patrol(); }
default { state_entry() { home = llGetPos(); functie_startup(); state patrol; //llOwnerSay((string)home); }
touch_start(integer total_number) { //llPlaySound("bark1", 1); } }
state patrol { state_entry() { //llSensorRepeat("", NULL_KEY, AGENT, 10, PI); llSensorRepeat("",NULL_KEY,AGENT,200,2*PI,0.5); llSay(0,"State Patrol"); //functie_sensor(); functie_startup(); //COORDINATEN destination1 = home + < 4., 0., 0.>; destination2 = home + < 3., -3., 0.>; destination3 = home + < 0., -4., 0.>; destination4 = home + <-3., -4., 0.>; destination5 = home + <-3., -3., 0.>; destination6 = home + <-3., 4., 0.>; destination7 = home + < 0., 4., 0.>; destination8 = home + < 3., 3., 0.>; functie_patrol(); }
sensor(integer total_number) { llSay(0,"TARGET FOUND!"); llStopMoveToTarget(); state attack; } no_sensor() { llSay(0,"where are you?"); } }
state attack { state_entry() { llSay(0,"state attack"); llLoopSound("growl", 1.0); llStopMoveToTarget(); functie_sensor(); }
sensor(integer total_number) { vector position = llDetectedPos(0); llMoveToTarget(position +offset*llDetectedRot(0),0.3); llLookAt(position, 4 , 0.03); vector currentposition = llGetPos(); float DistanceToHome = llVecDist(home, currentposition); if ( DistanceToHome >= 20) { llStopSound(); state retreat; llMoveToTarget(home, 0.5); } } }
state retreat { state_entry() { llPlaySound("bark2",1.0); llSay(0,"state Retreat"); llMoveToTarget(home, 3); llSleep(1); state default;
} }
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-27-2007 04:54
From: Sebastiaan Siegel thanks for the help. i read somewhere that a single prim cant have multiple sensors.
But is it possible to have multiple sensors in a single script but in different states? You can only have one active set of sensor paramteres per prim, but you are free to change then as often as you like. One point about your guard dog, it will currently only ever attack the owner.... try llSensorRepeat("", "", AGENT, 96.0, PI, 0.5);
|
|
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
|
03-28-2007 05:26
I can see the headline: Guard Dog Bites the Hand That Feeds It.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
03-28-2007 05:59
From: Sterling Whitcroft I can see the headline: Guard Dog Bites the Hand That Feeds It. or Burglar rescues owner from guard dog
|