joshua Bumbo Posted January 19, 2017 Share Posted January 19, 2017 I have a Linkset of 27 Prims whitch is a go cart. Here is a chart of prims, note card and a partial script. What I need it to do is to load the note card as varibles and then set lines 1 - 3 as vectors. I need it to also always sit on prim 1 (Root Prim). I have been tring for 4 and a half hours to no avail any help would be appriciated.//---------------------------------------------Part List--------------------------------------------------------// //1 Sit Box 5 Tire Front Left 9 Tire Back Right 13 Balloon Middle 17 Balloon Stick Right //2 Main Body 6 Rim Front Right 10 Rim Back Left 14 Balloon Right //3 Motor 7 Tire Front Right 11 Tire Back Left 15 Balloon Stick Left //4 Rim Front Left 8 Rim Back Right 12 Balloon Left 16 Balloon Stick Middle //--------------------------------------------------------------------------------------------------------------////---SETTINGS NOTECARD---// POSITION=<-0.45,0.0,0.7> ROTATION=<0.0,0.0,0.0> COLOR=<1.0,0.0,0.0>Original Drivers Script (No Errors)integer Private = 1; // Change to 1 to prevent others riding. integer tt; integer Gear = 1; integer Run; integer oldn; vector Sitpos = <.8,0,.8>; vector SitrotV = <0,0,0>; rotation Sitrot; key oldagent; key agent; float forward_power = 3; //Power used to go forward (1 to 30) float forward_normal = 3; float crash_power_forward = 3; float reverse_power = -3; //Power ued to go reverse (-1 to -30) float turning_ratio = 1.3; //How sharply the vehicle turns. Less is more sharply. (.1 to 10) float Speed; string sit_message = "Ride"; //Sit message string not_owner_message = "You are not the owner of this vehicle."; //Not owner message string DrivingAnim = "Default"; //Animation to use when owner sits /////////////////////////////// go_up() { llSetStatus(STATUS_PHYSICS, FALSE); llSetRot(<0,0,0,0>); llSetStatus(STATUS_PHYSICS, TRUE); } setCamera(float degrees) { rotation sitRot = llAxisAngle2Rot(<0, 0, 1>, degrees * PI); llSetCameraEyeOffset(<-10, 0, 3> * sitRot); llSetCameraAtOffset(<4, 0, 3> * sitRot); llForceMouselook(FALSE); } setVehicle() { llSetVehicleType(VEHICLE_TYPE_CAR); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.1); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.2); llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.2); llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 0.10); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.2); llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.2); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.1); llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.5); } Init() { Run = 0; llSetVehicleType(VEHICLE_TYPE_NONE); llSetStatus(STATUS_PHYSICS, FALSE); Sound(0); vector rotv = llRot2Euler(llGetRot()); rotation rot = llEuler2Rot(<0,0,rotv.z>); llSetRot(rot); Sitrot = llEuler2Rot(DEG_TO_RAD * SitrotV); } Reset() { Run = 0; vector rotv = llRot2Euler(llGetRot()); rotation rot = llEuler2Rot(<0,0,rotv.z>); llSetRot(rot); llSetPos(llGetPos() + <0,0,0.5>); } integer LastSetMaterial = FALSE; SetMaterial() { if(LastSetMaterial == FALSE) { LastSetMaterial = TRUE; } } Sound(integer n) { if(n != oldn) { oldn = n; if(n == 2) { llStopSound(); } else if(n == 1) { //llLoopSound("plane",1); } else { llStopSound(); } } } default { state_entry() { Init(); llSetSitText(sit_message); llSitTarget(Sitpos, Sitrot); setCamera(0); } on_rez(integer rn) { llResetScript(); llSetPos(llGetPos() + <0,0,.5>); } link_message(integer sender, integer num, string message, key id) { if(message=="reset") { Reset(); } } changed(integer change) { if ((change & CHANGED_LINK) == CHANGED_LINK) { agent = llAvatarOnSitTarget(); if (agent != NULL_KEY) { if( (agent != llGetOwner())) { llSay(0, not_owner_message); llUnSit(agent); llPushObject(agent, <0,0,50>, ZERO_VECTOR, FALSE); } else { llSetStatus(STATUS_PHYSICS, TRUE); llSleep(.4); oldagent = agent; setVehicle(); SetMaterial(); llSetTimerEvent(0.3); llMessageLinked(LINK_SET, 0, "shift", "1"); llRequestPermissions(agent, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS); Sound(1); Run = 1; } } else { Run = 0; llReleaseControls(); llStopAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); Init(); llSetPos(llGetPos() + <0,0,0>); Sound(0); } } } run_time_permissions(integer perm) { if (perm) { forward_power = forward_normal; Gear = 2; llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE); llPlaySound("start",1.0); llMessageLinked(LINK_SET, 0, "shift", "2"); llSetPos(llGetPos() + <0,0,0.5>); llStartAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); llWhisper(0,"Hit M for mouselook, page up and down for thrust control. If you flip, Stand Up to flip the vehicle right-side up."); } } control(key id, integer level, integer edge) { if(Run == 0) { llStopAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); return; } integer reverse=1; vector angular_motor; vector vel = llGetVel(); Speed = llVecMag(vel); if ((level & edge & CONTROL_UP) || ((Gear >= 7) && (level & CONTROL_UP))) { Gear=Gear+1; if(Gear == 1) { llSay(0,"Gear 1"); //llLoopSound("gear1",1); llMessageLinked(LINK_SET, 0, "shift", "1"); } if(Gear == 2) { llSay(0,"Gear 2"); //llLoopSound("gear1",1); llMessageLinked(LINK_SET, 0, "shift", "2"); } if(Gear == 3) { llSay(0,"Gear 3"); //llLoopSound("gear2",1); llMessageLinked(LINK_SET, 0, "shift", "3"); } if(Gear == 4) { llSay(0,"Gear 4"); //llLoopSound("gear3",1); llMessageLinked(LINK_SET, 0, "shift", "4"); } if(Gear == 5) { llSay(0,"Gear 5"); //llLoopSound("gear4",1); llMessageLinked(LINK_SET, 0, "shift", "5"); } if(Gear == 6) { llSay(0,"Gear 6"); //llLoopSound("gear5",1); llMessageLinked(LINK_SET, 0, "shift", "6"); } if (Gear < 1) Gear = 1; if (Gear > 6) Gear = 6; } if ((level & edge & CONTROL_DOWN) || ((Gear >= 7) && (level & CONTROL_DOWN))) { Gear=Gear-1; if(Gear == 1) { llSay(0,"Gear 1"); //llLoopSound("gear1",1); llMessageLinked(LINK_SET, 0, "shift", "1"); } if(Gear == 2) { llSay(0,"Gear 2"); //llLoopSound("gear1",1); llMessageLinked(LINK_SET, 0, "shift", "2"); } if(Gear == 3) { llSay(0,"Gear 3"); //llLoopSound("gear2",1); llMessageLinked(LINK_SET, 0, "shift", "3"); } if(Gear == 4) { llSay(0,"Gear 4"); //llLoopSound("gear3",1); llMessageLinked(LINK_SET, 0, "shift", "4"); } if(Gear == 5) { llSay(0,"Gear 5"); //llLoopSound("gear4",1); llMessageLinked(LINK_SET, 0, "shift", "5"); } if(Gear == 6) { llSay(0,"Gear 6"); //llLoopSound("gear5",1); llMessageLinked(LINK_SET, 0, "shift", "6"); } if (Gear < 1) Gear = 1; if (Gear > 6) Gear = 6; } if(level & CONTROL_FWD) { llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 2.0, 1000.0>); llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <Gear*forward_power,0,0>); llStartAnimation("Default"); reverse=1; } if(level & CONTROL_BACK) { llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <10.0, 2.0, 1000.0>); llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <Gear*reverse_power,0,0>); llStartAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); reverse = -1; } if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT)) { llStartAnimation("car right"); llStopAnimation("Default"); llStopAnimation("car left");; angular_motor.z -= Speed / (turning_ratio*Gear); } else { llStartAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); } if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT)) { llStartAnimation("car left"); llStopAnimation("Default"); llStopAnimation("car right"); angular_motor.z += Speed / (turning_ratio*Gear); } else { llStartAnimation("Default"); llStopAnimation("car left"); llStopAnimation("car right"); } llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor); } timer() { if(Run == 1) { vector pos = llGetPos(); float Z = pos.z; if(Z < 20) { llSetVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY); llSetVehicleFloatParam(VEHICLE_BUOYANCY, 1 ); llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 20); } else { llRemoveVehicleFlags(VEHICLE_FLAG_HOVER_WATER_ONLY); llSetVehicleFloatParam(VEHICLE_BUOYANCY, 0 ); } vector vel = llGetVel(); Speed = llVecMag(vel); if(Speed > 2.0) { Sound(2); } else if(Speed > 0.0) { llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <1.0, 2.0, 1000.0>); llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0,0,0>); Sound(1); } llSetTimerEvent(0.3); } else { llSetTimerEvent(0.0); } } } Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 19, 2017 Share Posted January 19, 2017 Reading variables from a notecard is fortunately a very straightforward exercise. You'll find a simple example in the LSL wiki for llGetNotecardLine. The bigger question is what you intend to use those variables for. You've selected a rather complicated job for a new scripter, and it looks like your vehicle contains other scripts that this one talks to. In order to know how to handle those three variables once you have read them in, you'll need to think through what they do first. That's not particularly obvious from anything you have said so far. You might also ask yourself whether these three parameters are things that you'll want to change frequently. If not, maybe you don't need to bother with a notecard. Just write them into the script itself. The sit target business should be working already. The vehicle's sit target is defined in state_entry, using the global parameters that are defined right at the top of the script. Since the target is set in this main script, which should be in the vehicle's root prim, you should always end up sitting on the root priim. Link to comment Share on other sites More sharing options...
Xiija Posted January 19, 2017 Share Posted January 19, 2017 I agree with Rolig, if they don't change, just add them to the script as variables.. If you want to read from a notecard you will need a data server event, and parse each line to set them.... here is a small example to help you understand it.. vector myPos; vector myRot; vector myCol; integer iLine; key kQuery;default{ state_entry() { kQuery = llGetNotecardLine(NC, iLine); } dataserver(key query_id, string data) { if (query_id == kQuery) { if (data == EOF) { iLine = 0; llSay(0,"Notecard Loaded"); } else { if(data != "") { list extract = llParseString2List(data,[" "],["="]); string setting = llList2String(extract, 0); string vec = llList2String(extract,2) ; if( setting == "POSITION") { myPos = (vector)vec; } if( setting == "ROTATION") { myRot = (vector)vec; } if( setting == "COLOR") { myCol = (vector)vec; } } ++iLine; kQuery = llGetNotecardLine(NC, iLine); } } } } e Link to comment Share on other sites More sharing options...
joshua Bumbo Posted January 19, 2017 Author Share Posted January 19, 2017 What the notecard is loading is the position and the rotation of the sit (so many avatars in so many sizes!) I was tring to make it really easy for the users to adjust there carts. Im seasoned in other scripting languages and not to mention love a challenage. I remember when i got my first car and i had to go into a script to edit the sit target i was so overwelmed with all the code even being use to looking at code. Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 19, 2017 Share Posted January 19, 2017 That's a good goal. Unfortunately, users who need to adjust their carts are probably not familiar enough with vectors and rotations to figure out what numbers to put in a notecard. You might want to consider either adding a commercial script like AvSitter to your vehicle or writing a stripped down routine for yourself. It's not much of a challenge to write a menu-driven system that lets users rotate or move an av up and down in discrete steps. Link to comment Share on other sites More sharing options...
joshua Bumbo Posted January 19, 2017 Author Share Posted January 19, 2017 like make it 0.0 then move the root prim itself through a menu system? Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 19, 2017 Share Posted January 19, 2017 Not the root prim. The avatar. Once an avatar is seated on a link, the avatar becomes the final link in the linkset, so you can move it the same way that you move any other link. For example, in a really simple-minded way (not involving a menu at all, but simply a touch trigger).... touch_start(integer num){ if (llAvatarOnSitTarget()) // Check to be sure that someone is sitting { // llGetNumberOfPrims() is the link number of the seated avatar vector CurrPos = llList2Vector(llGetLinkPrimitiveParams(llGetNumberOfPrims(),[PRIM_POS_LOCAL]),0); llSetLinkPrimitiveParamsFast(llGetNumberOfPrims(),[PRIM_POS_LOCAL,CurrPos + <0.0,0.0,0.05>]); }} So, touching the object will move the seated avatar up 0.05m relative to its current position. If you fold that logic into a dialog menu, you can use dialog menu buttons to move or rotate the av by a preset amount with each button click. Link to comment Share on other sites More sharing options...
joshua Bumbo Posted January 20, 2017 Author Share Posted January 20, 2017 I did not know that once someone sits they become a link Prim. Luckily I built a visual basics Project based off of building multi-layer menus. Thanks by the way for helping me so far. Link to comment Share on other sites More sharing options...
Recommended Posts
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