mayaeight Posted November 19, 2017 Share Posted November 19, 2017 I have a mountain tram and found an excellent script to get it up the mountain. The problem is that before it begins moving, the whole tram flips 90 degrees on its side and 180 degrees around so that is goes up the mountain sideways and backwards. I am new at this and I do not know what to do. Here is the script integer direction; integer curPoint; list points; string route; integer nextStation =-1; integer isPaused; float OFFSET=0; float SPEED = 1.75; //meters /second vector INITROTATION=<0,0.0>; float WATERHEIGHT = 20.05; integer channel = -9453; list messages; list delays; list messageTimes; integer curMessage; beginRoute(list points) { llSetKeyframedMotion( [], []); //llSetRot(ZERO_ROTATION); llSleep(0.3); messageTimes = []; curMessage = 0; OFFSET=(float)llGetObjectDesc(); vector pos = llList2Vector(points,0); llSetRegionPos(pos); llSetRot(llEuler2Rot(INITROTATION)); rotation rot = llEuler2Rot(INITROTATION); integer i; list kf; float totTime =0; messageTimes = []; for (i=0; i < llGetListLength(points); i++) { vector v = llList2Vector(points, i); rotation r2 = llEuler2Rot(INITROTATION); if (i < llGetListLength(points)-1) { vector vn = llVecNorm(llList2Vector(points, i+1) - v); // break rotation in 2 parts: along Z, then along the rest. llRotBetween would turn the train upside-down vector v2 = vn; v2.z =0; rotation r2a = llRotBetween(<1,0,0>, v2); // Rotation along the Z axis only rotation r2b = llRotBetween(<1,0,0>*r2a, vn); r2 = r2a*r2b; //llRotBetween(<1,0,0>,vn); } else { r2 = rot; //v.y -= OFFSET; // boat Parking offset } vector cor = llRot2Euler(r2); if (cor.x == -PI) cor.x = PI; //cor.x=0; // Remove any rotation around X r2 = llEuler2Rot(cor); float t; if (i>0) { kf += (1.0)*(v-pos); kf += ZERO_ROTATION; t = llVecMag(v-pos)/SPEED; //adjust for speed kf += t*(1.0); rotation myrot = llRotBetween(<1,0,0>*rot, <1,0,0>*r2); kf += ZERO_VECTOR ; kf += r2 / rot; // myrot; //llEuler2Rot(<0,cor.y,0>); kf += .5; } else // the zero-th frame is just a rotation { kf += ZERO_VECTOR; kf += (r2/rot); kf += 2; //adjust for speed t = 2; } kf += ZERO_VECTOR; kf += ZERO_ROTATION; float delay = llList2Float(delays, i); kf += delay; //adjust for speed t += delay; totTime+= t; pos = v; rot = r2; messageTimes += (t+1 ); } //llLoopSound("paddle", 1.0); llSetKeyframedMotion( kf, [KFM_DATA, KFM_TRANSLATION|KFM_ROTATION, KFM_MODE, KFM_PING_PONG]); llMessageLinked(LINK_SET, 0, "START", ""); llStopSound(); llSleep(.1); llLoopSound("train", 1.); } doStop() { isPaused = !isPaused; if (isPaused) llSetKeyframedMotion( [], [KFM_COMMAND, KFM_CMD_PAUSE]); else llSetKeyframedMotion( [], [KFM_COMMAND, KFM_CMD_PLAY]); if (isPaused) { llMessageLinked(LINK_SET, 0, "STOP", ""); llStopSound(); } else { llMessageLinked(LINK_SET, 0, "START", ""); llLoopSound("train", 1.); } } default { state_entry() { llSitTarget(ZERO_VECTOR, ZERO_ROTATION); llListen(channel,"", "",""); llMessageLinked(LINK_SET, 0, "STOP", ""); } listen(integer chan, string n, key sender, string cmd) { if (cmd == "Pause/Cont") { doStop(); } else if (cmd == "PANIC") { llSetKeyframedMotion([], []); llStopSound(); llSetTimerEvent(0); } else if (cmd == "Reset11") { list lines = llParseString2List(osGetNotecard("route"), ["\n"], []); integer j=0; { list tk = llParseString2List(llList2String(lines,j), ["|"], []); vector p= llList2Vector(tk,0); // llSay( 0, (string)p); llSetRegionPos(p); llSetRot( llEuler2Rot(INITROTATION)); } } else if (cmd == "Reset") { list lines = llParseString2List(osGetNotecard("route"), ["\n"], []); integer j; points = []; delays = []; messages = []; for (j=0; j < llGetListLength(lines); j++) { list tk = llParseString2List(llList2String(lines,j), ["|"], []); points += llList2Vector(tk,0); delays += llList2Float(tk,1); messages += llList2String(tk,2); } beginRoute(points); } } touch_start(integer n) { if (llDetectedKey(0) == llGetOwner()) llDialog(llDetectedKey(0), "Select", ["Reset", "Pause/Cont", "PANIC", "CLOSE"], channel); } changed(integer change) { if (change & CHANGED_LINK) { integer i; for (i=2; i < llGetNumberOfPrims(); i++) if (llAvatarOnLinkSitTarget(i) != NULL_KEY) // llGetNumberOfPrims() > llGetObjectPrimCount(llGetKey())) { llSetTimerEvent(2); // llOwnerSay("Seated"); return; } { //else llSetTimerEvent(0); } } } timer() { integer i; for ( i=0; i < llGetListLength(points); i++) { if (llVecDist(llGetPos(), llList2Vector(points,i))< 7) { // llOwnerSay("PT = "+i); if (i != nextStation) { string s = llList2String(messages, i); if (s != "") { llWhisper(0 , "/me <<" +s+ ">>"); llTriggerSound("dingdong", 1.0); } nextStation = i; return; } } } } } Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 19, 2017 Share Posted November 19, 2017 At a quick glance, it looks like you just need to change the initial rotation of the tram:vector INITROTATION=<0,0,0>; It's easiest to do by just fiddling with it experimentally. If I were standing there and playing with it myself, though, I would probably start by turning it 180 degrees on its Z axis and 90 degrees on the X axis:vector INITROTATION=<PI/2,0,PI>; If the X rotation is the wrong way, so the car is on its back, try vector INITROTATION=< -PI/2, 0,PI>; With any luck, that's all it will take. Otherwise, your best move is to hire a scripter to come and play with it. 2 Link to comment Share on other sites More sharing options...
Innula Zenovka Posted November 20, 2017 Share Posted November 20, 2017 Before touching the script, I would examine the train object, using the in-world editor with the ruler set to Local rather than to World: Check which way the object's positive x axis (the red arrow) is pointing. If it's not pointing in the same direction as the front of the train (and it sounds to me as if it isn't) then give the object a new root prim, comprising a simple cube, set as invisible, pointing in the same direction as the front of the train. Then put your script in the new root prim and see what happens. 3 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