Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

listening sensor?

azure Milev
Registered User
Join date: 5 Jan 2008
Posts: 4
11-08-2008 23:23
Hello, I do not understand sensors at all, and after three days of reading and experimenting with this code... I seems to be confusing myself even more. Can anyone help?

integer shoutchan = 0;
integer SHOUTCHANX;

string OBJECTtoFOLLOW = "wall2";
vector offsetsensor = ZERO_VECTOR;
rotation baserot = ZERO_ROTATION;

default
{
state_entry()
{
SHOUTCHANX = llListen(shoutchan, "","","";);
}



listen(integer SHOUTCHANX, string name, key id, string message)
{
if ( message == "fullON" ){
llSensorRemove();
llSay(0, "Follow Off";);
}
else if ( message == "fullOFF" ){
llSensorRepeat(OBJECTtoFOLLOW, "", ACTIVE | PASSIVE, 20.0, PI, 1.0);
llSay(0, "Following";);
}
}

sensor(integer det)
{
rotation rot = llDetectedRot(0);
if (offsetsensor == ZERO_VECTOR) // store offset once
{
baserot = llGetRot() / rot;
offsetsensor = (llGetPos() - llDetectedPos(0)) / rot;;
}

llSetPrimitiveParams([
PRIM_ROTATION, llDetectedRot(0) * baserot,
PRIM_POSITION, llDetectedPos(0) + (offsetsensor * rot) ]);
}

no_sensor()
{
offsetsensor = ZERO_VECTOR;
}

}

The channels and what not will be neccessary, this script will be merged into a larger script that listens to a dialogue menu. This is my last hurdle in completing my project and it's starting to give me a headache. lol Thanks for any help you can offer.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
11-09-2008 00:08
I think you'll have to explain what exactly you are trying to do with your math. llGetPos() is your object's current position. llDetectedPos() and llDetectedRot() give you the position and rotation (respectively) of the object you are looking for. I think you're making things a little complicated. Looking closely, I can see that the position you are trying to move the object to is always going to be the same as its current position, for example.
azure Milev
Registered User
Join date: 5 Jan 2008
Posts: 4
Nvm
11-09-2008 19:46
Nevermind I got it to work. it was just a simple typo. lol

And to answer your question, the object this script is in will follow (rotate and what not) to match it's orientation with the object called "wall2" (the main structure). It was for my freebie builder pool pack I made. I wanted a way for the phantom water to be able to follow the main structure incase the user forgot to select it when they were positioning the main structure. but because the follow script interfers with the water rising and emptying code, I was making it to only excute the follow command when the water was on empty mode (it's default state).