Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vehicle Problem: Passenger sits, vehicle resets.

Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
08-09-2009 04:52
Okay, so I'm making a boat. It's a pretty daunting task, to be honest. I started out with one of the well worn freebie boat scripts, then began tweaking physics settings, adding features, sounds, etc etc.

So now the script has quite a bit going on with it. But in iit's heart, it's still that basic boat script.

When the linkset changes.. if there's a non-NULL_KEY on the sit target (someone is sitting), it does a test. If the sitter is the owner, the boat script goes into active mode (and plays a little sound to let me know it's ready to go). If the sitter on the sit target is NOT the owner, it boots them (standard behaviour). If there's NULL_KEY on the sittarget, then the vehicle shuts down.

So here's the problem. I added some additional seats. They're all pretty basic in themselves. Sit targets of their own.. the sit scripts seem to "know" when an avatar is sitting on that given prim.. and it acts accordingly (plays an animation for them).

BUT the main boat script is also aware that "someone sat on the boat".. and when the Owner is already seated.. it polls the linkset and says "hey, the owner is sitting on the sit target" so it starts the vehicle... again.

Is there some sort of standard practice for solving this problem? Is it as simple as adding a flag "driverSitting = TRUE".. when the driver is first detected and clearing it when the driver leaves? Or is there some, more elegant method by which to ignore the sitters on child prims?

(P.S... is it REALLY still neccessary to set STATUS_BLOCK_GRAB in every prim of the linkset?)
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
08-09-2009 05:01
The normal way to do this is to use states. When the vehicle's just sitting there waiting for a driver you have a nice simple state that just detects a sitter and does the permissions checks and then switches state to the active state. In the active state you take controls for the driver, and watch run_time_permissions. When the driver stands up you'll lose PERMISSION_TAKE_CONTROLS, then you go non-physical and switch back to the default state waiting for a new driver.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
08-09-2009 10:18
or w/o states
CODE

//-- in globals
integer gIntEmpty = TRUE;

//-- in changed
if (llAvatarOnSitTarget() == llGetOwner()){
if (gIntEmpty)
gIntEmpty = FALSE;
//-- start boat
}
}else{
llUnsit( llAvatarOnSitTarget );
gIntEmpty = TRUE;
//-- stop boat
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
08-09-2009 10:25
That's still using states, you're just implementing the states by hand instead of letting LSL do it for you. You can add a state variable and add a check in all the events to see if you're in the right state or not, but this is a situation where explicit states are a clear winner. The behavior of a vehicle when it's being driven and when it's not are completely different. The code is simpler because you can completely eliminate the events you don't care about in the resting state.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-09-2009 11:16
when using multiple states, in the active state, you can use the changed link test that's used in most pose scripts that i've seen.

changed(integer change)
{
if(change & CHANGED_LINK)
{
if(llAvatarOnSitTarget() == NULL_KEY){llResetScript();}
}
}

there's no else in there to make it do anything if the owner is still seated, so it should just continue running as normal
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369