Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

vehicle listening only to pilot

Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
11-06-2008 20:29
how can i make a vehicle listen only to text from the seated pilot? i want to have keyboard commands for some special function in my vehicle, such as "hatch open" and "hatch shut" or "lights on or off", so i would type "o" or "s" in the open channel, and the vehicle performs the function. This works great, unless there's TWO such vehicles, or another passenger in one vehicle, and their letters can also affect the vehicle! it's cumbersome to type in specific channel when driving around, but i lack the vocabulary to find the right bit of code to have it obey only the seated driver...

any help most appreciated!

-HN
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
11-06-2008 22:05
The solution is simple: Filtering the llListen().

I suppose you must detect when an AV is sitting with a changed() event. That's the right moment to get a key... and to use it or not.

key Driver;
integer Handle;
integer Channel;

changed(integer change)
{
if (change & CHANGED_LINK)
{
Driver = llAvatarOnSitTarget();
if (Driver != NULL_KEY)
{
// An avatar just sat...
Handle = llListen(Channel, "", Driver, "";);
}
else
{
// Avatar just stood up...
llListenRemove(Handle);
}
}
}

Of course, you must put a sit script in every seat and only the driver seat listens.
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
11-06-2008 23:55
thanks! i'll give it a try!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
11-07-2008 05:39
in multiseat vehicles, just make sure that it checks the position of that avatar on the sittarget, is the right sit target...
_____________________
|
| . "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...
| -