[Opensim-users] Wear Your Vehicle Script
Kay McLennan
mclennan.kay at gmail.com
Sun Feb 26 15:57:44 UTC 2012
To the group discussing the "Does OpenSim Fully Support Linden [Vehicle]
Scripts? (read: Han, Garmin, InuYasha, Wade, R.Gunther, Justin, Karen,
M.E., etc.),
I found a splendid "Wear your vehicle" script that works in the OpenSim--
see below. Further, when the vehicle is worn in concert with an avatar
flying, the script works for airplanes too (in the OpenSim)!
Best,
Kay
// Put this script in an object you wish to wear to appear to ride it,
include any animation for the AV to assume, in the Root Prim's contents.
First Attach to Pelvis, then you may just wear.
string SitAO = "DriveCar2";// Replace sit with the animation's name you
include in object contents
default
{
attach(key id)
{
if(id)//tests if it is a valid key and not NULL_KEY and gets
permission to read the contols keys and start animation
{
llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION
| PERMISSION_TAKE_CONTROLS);
llStartAnimation(SitAO);//animation name is put here
llTakeControls(CONTROL_FWD |CONTROL_BACK |CONTROL_LEFT
|CONTROL_RIGHT |CONTROL_ROT_LEFT |CONTROL_ROT_RIGHT |CONTROL_UP
|CONTROL_DOWN |CONTROL_LBUTTON |CONTROL_ML_LBUTTON |0, TRUE, TRUE);//Takes
controls but passes them on to the Avatar too
llPlaySound("Sportscarstarts",1);
llSleep(1);
llLoopSound("Sportscaridle",.75);
}
else
{
llStopAnimation(SitAO);//animation name is put here too
}
}
control(key id, integer level, integer edge)//Event triggered when any
key is pressed or relased
{
integer start = level & edge;//define start as key was pressed
integer end = ~level & edge;//define end as key was released
integer held = level & ~edge;//define key is being held down
integer untouched = ~(level | edge);//define that no keys are
pressed
if(start & CONTROL_FWD)
{
//llSay(0,"Fwd Key was pressed");
llMessageLinked(LINK_SET, 0, "RF", "");//sends messgage to all
other scripts RF=Right Forward
llMessageLinked(LINK_SET, 0, "LF", "");//sends messgage to all
other scripts LF=Left Forward
llMessageLinked(LINK_SET, 0, "SF", "");//sends messgage to all
other scripts SF=Spin Forward
llLoopSound("Sportscardriving",1);//Driving sound
}
if(end & CONTROL_FWD)
{
//llSay(0,"Fwd Key was released");
llMessageLinked(LINK_SET, 0, "RS", "");//sends messgage to all
other scripts RS=Right Stop
llMessageLinked(LINK_SET, 0, "LS", "");//sends messgage to all
other scripts LS=Left Stop
llMessageLinked(LINK_SET, 0, "SS", "");//sends messgage to all
other scripts SF=Spin Stop
llLoopSound("Sportscaridle",.5);//Idle Sound
}
if(start & CONTROL_BACK)
{
llMessageLinked(LINK_SET, 0, "RR", "");//sends messgage to all
other scripts RS=Right Reverse
llMessageLinked(LINK_SET, 0, "LR", "");//sends messgage to all
other scripts LS=Left Reverse
llMessageLinked(LINK_SET, 0, "SR", "");//sends messgage to all
other scripts SF=Spin Reverse
}
if(end & CONTROL_BACK)
{
llMessageLinked(LINK_SET, 0, "RS", "");//sends messgage to all
other scripts RS=Right Stop
llMessageLinked(LINK_SET, 0, "LS", "");//sends messgage to all
other scripts LS=Left Stop
llMessageLinked(LINK_SET, 0, "SS", "");//sends messgage to all
other scripts SF=Spin Stop
}
if((start & CONTROL_RIGHT) | (CONTROL_ROT_RIGHT == (start)))
{
llMessageLinked(LINK_SET, 0, "TR", "");//send TR to front tires
llMessageLinked(LINK_SET, 0, "LF", "");//sends messgage to all
other scripts LS=Left Forward
}
if((end & CONTROL_RIGHT) | (CONTROL_ROT_RIGHT == (end)))
{
if(held & CONTROL_FWD)//If Forward is held don't stop
{}
else
{
llMessageLinked(LINK_SET, 0, "LS", "");//sends
messgage to all other scripts LS=Left Stop
}
llMessageLinked(LINK_SET, 0, "TS", "");//Straighten tires when
key released
}
if((start & CONTROL_LEFT) | (CONTROL_ROT_LEFT == (start)))
{
llMessageLinked(LINK_SET, 0, "TL", "");//send TL to front tires
llMessageLinked(LINK_SET, 0, "RF", "");//sends messgage to all
other scripts RF=Right Forward
}
if((end & CONTROL_LEFT) | (CONTROL_ROT_LEFT == (end)))
{
if(held & CONTROL_FWD)//If Forward is held don't stop
{}
else
{
llMessageLinked(LINK_SET, 0, "RS", "");//sends
messgage to all other scripts RS=Right Stop
}
llMessageLinked(LINK_SET, 0, "TS", "");//Straighten tires when
key released
}
// for flying
if(level & CONTROL_UP)
{
//llSay(0,"Page Up");
}
if(level & CONTROL_DOWN)
{
//llSay(0,"Page Down");
}
// End of
FLying
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20120226/adf95b95/attachment.html>
More information about the Opensim-users
mailing list