Eliwood407 Posted September 28, 2013 Share Posted September 28, 2013 Hello there!I have tried many ways I could emagine to make a simple vehicle script say something (text or string) when it starts walking, and when it starts stopping.I am making a robot with 4 legs, the legs move like a bug or spider, which I will puppeteer.To make the puppeteered legs walk and stop walking, I would have to make the vehicle script say a command.However, when I try to tinker with Velocity and whatnot, it will spam the command very fast, I don't know how to make it say the command once.Does anyone have an idea what would be the best for this?I add the vehicle script to this post for the sake of showing what I have.I do not expect anyone to do the work for me ^^ /////////////////////////////////// //Simple RC Chopper Script// /////By Mrc Homewood/////// /////if used include credit///// ////////////////////////////////// float speed = 0; float turn = 0; float lift = 0; integer move = FALSE; integer turningR = FALSE; integer turningL = FALSE; integer TURNING; integer RUNNING; integer Fire; integer Mine; integer Talk; vector left_vel = <0,0,-2>; key avatar; integer on; default { state_entry() { llSetObjectName("Default Immortal"); llSetVehicleType(VEHICLE_TYPE_CAR); llRemoveVehicleFlags(VEHICLE_FLAG_LIMIT_MOTOR_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY); llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <1, 2, 1> ); llSetVehicleVectorParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1.5,1.5,1.5> ); llSetVehicleVectorParam( VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.2 ); llSetVehicleFloatParam( VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.75 ); llSetVehicleVectorParam( VEHICLE_ANGULAR_MOTOR_DIRECTION, <0, 0, 0> ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.2 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.3 ); llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 0.0 ); llSetVehicleFloatParam( VEHICLE_BUOYANCY, 0.0 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0 ); llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 2 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.8 ); llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 2 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5 ); llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 2 ); llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 0.7 ); llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.5 ); llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, 0.2 ); llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, <0, 0, 0, 1> ); llStopSound(); llCollisionSound("", 0.0); llSetStatus(STATUS_PHYSICS, FALSE); llOwnerSay("Tank is ready! Click to start!"); } touch_start(integer t) { avatar = llDetectedKey(0); string name=llKey2Name(avatar); if((on == TRUE)) { llSetStatus(STATUS_PHYSICS, FALSE); llStopSound(); llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE); llReleaseControls(); on = FALSE; } else if((on == FALSE)) { llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE); llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS); on = TRUE; llSay(0, llGetDisplayName(llDetectedKey(0)) +" entered a tank!"); } } run_time_permissions(integer perms) { if(perms & (PERMISSION_TAKE_CONTROLS)) { llTakeControls(CONTROL_UP | CONTROL_DOWN | CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE); llSetStatus(STATUS_PHYSICS, TRUE); Talk = !Talk; llWhisper(-2031, (string) Talk); } else { llReleaseControls(); llSetStatus(STATUS_PHYSICS,FALSE); } } control(key id, integer level, integer edge) { if (level & CONTROL_UP) { Fire = !Fire; llWhisper(-2002, (string) Fire); llSay(117, "Fire"); } if (level & CONTROL_DOWN) { Mine = !Mine; llWhisper(-2003, (string) Mine); llSay(117, "Mine"); } if (level & CONTROL_FWD) { speed = 1; // fwd power move = TRUE; } if (level & CONTROL_BACK) { speed = -0.5; // reverse power move = TRUE; } if (level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) { TURNING = -1; if (RUNNING > 0) { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, 0.6 * left_vel); } else { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, left_vel); } } else if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT)) { TURNING = 1; if (RUNNING > 0) { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, -0.6 * left_vel); } else { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, -1.0 * left_vel); } } else { TURNING = 0; llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, ZERO_VECTOR); } if(move) { llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <speed,0,lift>); lift = 0; speed = 0; move = FALSE; } if(turningR) { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <turn,-0,1>); turn = 0; turningR = FALSE; } if(turningL) { llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, <turn,0,1>); turn = 0; turningL = FALSE; } } on_rez(integer start_param) { llResetScript(); } } PS: I don't know how to change the title to [Resolved] when I get an answer ._. Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 28, 2013 Share Posted September 28, 2013 When you write if ( level & CONTROL_FWD ) the condition reports TRUE as long as you are holding down the FWD arrow key. It's the same as writing if ( level & ~edge & CONTROL_FWD ) Try writing if ( level & edge & CONTROL_FWD ){ llSay(0,"I'm moving!");}if ( ~level & edge & CONTROL_FWD ){ llSay(0,"I just stopped moving!");} I can't get in world at the moment to test, but I think that will work. Link to comment Share on other sites More sharing options...
steph Arnott Posted September 28, 2013 Share Posted September 28, 2013 I did, i was 500 meters up, it fell thru the floor and locked my movement. Had to log out and back in then find it. Link to comment Share on other sites More sharing options...
Rolig Loon Posted September 28, 2013 Share Posted September 28, 2013 Really, Steph? Wow. Try this, then. I just went in world to test, and it works just fine. default{ state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS); } run_time_permissions(integer perm) { if(PERMISSION_TAKE_CONTROLS & perm) { llTakeControls( CONTROL_FWD | 0, TRUE, FALSE); } } control(key id, integer level, integer edge) { integer start = level & edge; integer end = ~level & edge; integer held = level & ~edge; if ( start & CONTROL_FWD ) { llSay(0,"I'm moving!"); } if ( end & CONTROL_FWD ) { llSay(0,"I just stopped moving!"); } if (held & CONTROL_FWD) { llSetPos(llGetPos() + <0.1,0.0,0.0>*llGetRot()); } }} Link to comment Share on other sites More sharing options...
steph Arnott Posted September 28, 2013 Share Posted September 28, 2013 lol. Not your script the OPs I kept getting an error on the LSLEditor. ADDED: The joy of scripts, lol Link to comment Share on other sites More sharing options...
Eliwood407 Posted September 29, 2013 Author Share Posted September 29, 2013 Hey thank both of you ^^ My apologies if the script caused a problem It never happened to me I will apply the suggestions immediately ^^ I love the secondlife scripting forum and all it's helpers. WIthout you I would not be as far in scripting as I am now. I learn new things every time^^ Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now