Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vehicle changed event handler isolating

Badinage Odets
Registered User
Join date: 26 Sep 2005
Posts: 18
02-10-2007 15:00
Hello =^.^= I am scripting my latest sailing ship project for physical movement. And anyway I am having a lot of greif with the changed event handler. I encountered teh same problems back when I was making airplanes and never reallly figured it out. Anyway, the issue I have is that it works just fine for the captiian sitting/unsitting. BUT whenever 1 of the 7 passangers sit on it, peices of that event are get activated. The startup lines may be ran, sometimes parts of the shutting down lines are ran (but not all)

I want to get a way to reorganize this so it TOTALLY ignores any agent sitting/standing up from any of the sittargets in the various child prims in this craft. Here is the relevant section of code cleaned up a bit

CODE

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();

if(agent != llGetOwner() && agent != NULL_KEY)
{

llUnSit(agent);
llPushObject(agent, <0,0,10>, ZERO_VECTOR, FALSE);
}
else if(agent == llGetOwner())
{

gLinearMotor = <0, 0, 0>;
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);


llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1000.0);
llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1000.0);
llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS);
llSetStatus(STATUS_PHYSICS, TRUE);

llSay(0, "start ran");

}
else if(agent == NULL_KEY)
{

gLinearMotor = <0, 0, 0>;
llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, gLinearMotor);
llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, gLinearMotor);


llSetStatus(STATUS_PHYSICS, FALSE);
llSetVehicleFloatParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, 1.0);
anchor();
llSay(0, "shutdown ran");

}

}


}



Thanks for any help! ^_^
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
02-10-2007 16:17
I think your script needs to have a llsittarget command somewhere before you can detect the av in the changed listener. Strange, but it worked for me.


See the QA after the first lsl example here:
http://rpgstats.com/wiki/index.php?title=LlAvatarOnSitTarget
Badinage Odets
Registered User
Join date: 26 Sep 2005
Posts: 18
02-10-2007 16:52
There is a sittarget in state_entry and in the child prims for the other sitting positions too. But detecting them is exactly the bug im trying to fix (meaning I dont want to detect them). I'll look into avataronsittarget though! :D

n/m There is a AvataronSitTarget in there already.