Jump to content

Help with car scripts - Cycling Gears with only PgUp Key


Tamara Sierota
 Share

You are about to reply to a thread that has been inactive for 3281 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi... I need to be able to free up the PgDn Key in a driving script I'm working on.

Can anyone tell me how I change the gear settings below to make it cycle 2 gears (low and high) with just the PgUp Key?

Also wondering if anyone can help with a mesh wheel turning set up without placing a script in each wheel. 

if((level & edge & CONTROL_UP)&& gears < 1)
{
gears++;
llWhisper(0,"GEAR "+(string)(gears+1));
}
if((level & edge & CONTROL_DOWN)&& gears > 0)
{
gears--;
llWhisper(0,"GEAR "+(string)(gears+1));

 

Link to comment
Share on other sites

So, you want to just simplify that bit of code to make the PgUp key do all the work?  This code will just reverse the sense of gears (up or down, from TRUE to FALSE, or 1 to 0) each time you hit thePgUp key and will shift your gears:

 

if (level & edge & CONTROL_UP){    llWhisper(0,"GEAR" + (string) (gears = !gears));}

Incidentally, I strongly advise against communicating on the PUBLIC_CHANNEL like that.  If you have to send your messages by chat, use a unique, high negative integer, like -8377182.  You'll avoid crosstalk and chat lag.

Whether you can get away from having a separate script in each wheel depends on exactly how the wheels work.  It's hard to tell without knowing that.  Unless you are adept at handling rotations, though, I suspect that it's easiest to leave things the way they are.   

Link to comment
Share on other sites


Rolig Loon wrote:

So, you want to just simplify that bit of code to make the PgUp key do all the work?  This code will just reverse the sense of gears (up or down, from TRUE to FALSE, or 1 to 0) each time you hit thePgUp key and will shift your gears:

 
if (level & edge & CONTROL_UP){    llWhisper(0,"GEAR" + (string) (gears = !gears));}

Incidentally, I strongly advise against communicating on the PUBLIC_CHANNEL like that.  If you have to send your messages by chat, use a unique, high negative integer, like -8377182.  You'll avoid crosstalk and chat lag.

Whether you can get away from having a separate script in each wheel depends on exactly how the wheels work.  It's hard to tell without knowing that.  Unless you are adept at handling rotations, though, I suspect that it's easiest to leave things the way they are.   

BillThePirate often uses channel -8377182. I recommend -8675309.

Link to comment
Share on other sites

Thank you! That did the trick :)

I am using a basic drive script and modifying it.. scripting skills are mediocre but learning.... as I can't find any driving scripts to suit the project I'm working on.

If anyone is able to help with the channel setting in my drive script, creating a mesh rear wheel script to work with the drive script (hopefully without a script in each wheel)... and the ability to hide a mesh face and show another with a simple chat command I am happy to pay for your services.

Appreciate all the help and consideration to this request

Link to comment
Share on other sites


Tamara Sierota wrote:

[ .... ]

If anyone is able to help with the channel setting in my drive script, creating a mesh rear wheel script to work with the drive script (hopefully without a script in each wheel)... and the ability to hide a mesh face and show another with a simple chat command I am happy to pay for your services.

Appreciate all the help and consideration to this request

I'm glad it did the job.  For your other requests, though, the place to ask is in the InWorld Employment forum.  You'll find hungry scripters there who may rise to your challenge.

Link to comment
Share on other sites

ok thanks very much.. I've done that... just quickly on the driving script while I wait for a reply....

anyone know how I can add additional toque for hill climbing?

llSetVehicleType(VEHICLE_TYPE_CAR);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.80);
llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1.0);
llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1);
llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.1);
llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1000.0, 10.0, 1000.0> );
llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <500.0, 500.0, 1000.0> );
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.50);
llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.50);
llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0);

Thanks again everyone

Link to comment
Share on other sites

here is a snippet to rotate a link on the y axis,

it looks for a link named "dw" and only rotates the first one found...

you can change axis, rotate all drive wheels in a list etc,

or you could use target omega, or rotate a texture on a mesh face... not sure which you are doing

 

integer k;list drivewheels;string temp;integer link;default{    state_entry()    { integer prims = llGetNumberOfPrims();      integer n= 1;      for(;n <= prims; ++n)       {  if (llGetLinkName(n) == "dw")          { drivewheels += [n] ;          }       }       link =  llList2Integer(drivewheels,0);          }    touch_start(integer total_number)    { if(k = !k)        llSetTimerEvent(0.0625);      else        llSetTimerEvent(0.0);    }    timer()    {         list    params  = llGetLinkPrimitiveParams(link ,[PRIM_ROT_LOCAL]);         rotation wheelRot = llList2Rot(params,0);         rotation r = wheelRot*llEuler2Rot(<0, 45, 0>*DEG_TO_RAD);         llSetLinkPrimitiveParamsFast(link,         [ PRIM_ROT_LOCAL,r ]);    }}

 

Link to comment
Share on other sites

for hill climbing, try something like this?

( check  vehicle's rotation is more than a certain amt, if so , add power)

 if( level & CONTROL_FWD )
{  vector vRot = llRot2Euler( llGetRot() );
   float hill = -vRot.y * RAD_TO_DEG;     
   if(hill > 15)
  llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power + 20,0,0> );
  else
  llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power ,0,0> );
}

( not sure if you need to check rotation in a timer, or if you can do it in control)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3281 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...