Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Movement Prim_Movement_4_Axis  

Prim_Movement_4_Axis

Try it on a prim with the following dimensions
X = .01 Y = 5.0 Z =5.0

Category: Movement
By : mangowylder
Created: 2012-05-07 Edited: 2012-05-07
Worlds: Second Life

the Zip file

Download all files for Prim_Movement_4_Axis
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Prim_Movement_4_Axis_1.lsl
1 // Move a prim on four axis
2 // Z = Up Down, X = Forward Back, Y = Left Right, Rotate Left & Right around Z axis
3 // Moves .2 meters X, Y and Z
4 // Rotates 5 degrees around the Z axis
5 // Persistent LLDialog until user cancel
6
7 // Best illustrated using a flat board with the following dimensions
8 // Z = 5, X = .01, Y = 5
9 // Anyone that has played the now (05/07/12) defunct Byngo Bonus game
10 // will recognize this type of board movement
11
12 // Written by Mango Wylder
13
14 list gLstChoices = ["MoveDown", "MoveRight", "MoveBack", "MoveUp", "MoveLeft", "MoveForward", "RotateLeft", "RotateRight", "Cancel"];
15 integer gIntChannel_Dialog;
16 integer gIntListen_Id;
17 integer gIntMove = 1;
18 integer gIntVr;
19 key gKeyToucherID;
20 float gFltX;
21 float gFltY;
22 float gFltZ;
23 vector gVecPos;
24 vector gEul = <0,0,0>;
25
26
27 default
28 {
30 {
31 gIntChannel_Dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) ); // set a negative integer chat channel for the dialog box
32 }
33
34 touch(integer total_number){
35 gKeyToucherID = llDetectedKey(0);
36 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
37 gIntListen_Id = llListen(gIntChannel_Dialog, "", gKeyToucherID, "");
38 llSetTimerEvent(20); // set a time limit to llListen
39 // Adding .x .y or .z after the vector name can be used to get the float value of just that axis.
40 gVecPos = llGetPos();
41 gFltX = gVecPos.x; // <--- Like this.
42 gFltY = gVecPos.y;
43 gFltZ = gVecPos.z;
44 }
45 listen(integer channel, string name, key id, string choice) {
46 if(channel == gIntChannel_Dialog) {
47 if(~llListFindList(gLstChoices, [choice])) { // verify dialog choice
48 if(choice == "Cancel"){
49 llListenRemove(gIntListen_Id);
50 }
51 else if(choice == "MoveUp"){
52 gFltZ = gFltZ + .2;
53 llSetPos(< gFltX,gFltY,gFltZ>);
54 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
55 }
56 else if(choice == "MoveDown"){
57 gFltZ = gFltZ - .2;
58 llSetPos(< gFltX,gFltY,gFltZ>);
59 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
60 }
61 else if(choice == "MoveLeft"){
62 gFltY = gFltY - .2;
63 llSetPos(< gFltX,gFltY,gFltZ>);
64 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
65 }
66 else if(choice == "MoveRight"){
67 gFltY = gFltY + .2;
68 llSetPos(< gFltX,gFltY,gFltZ>);
69 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
70 }
71 else if(choice == "MoveForward"){
72 gFltX = gFltX + .2;
73 llSetPos(< gFltX,gFltY,gFltZ>);
74 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
75 }
76 else if(choice == "MoveBack"){
77 gFltX = gFltX - .2;
78 llSetPos(< gFltX,gFltY,gFltZ>);
79 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
80 }
81 else if(choice == "RotateLeft"){
82 gIntVr = gIntVr - 5;
83 gEul = <0,0,gIntVr>; //5 degrees around the z-axis, in Euler form
84 gEul *= DEG_TO_RAD; //convert to radians
85 rotation quat = llEuler2Rot(gEul); //convert to quaternion
86 llSetRot(quat); //rotate the object
87 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
88 }
89 else if(choice == "RotateRight"){
90 gIntVr = gIntVr + 5;
91 gEul = <0,0,gIntVr>; //5 degrees around the z-axis, in Euler form
92 gEul *= DEG_TO_RAD; //convert to radians
93 rotation quat = llEuler2Rot(gEul); //convert to quaternion
94 llSetRot(quat); //rotate the object
95 llDialog(gKeyToucherID, "Please make a choice.", gLstChoices, gIntChannel_Dialog);
96 }
97 }
98 }
99 }
100 timer() { //TIME’S UP!
101 llListenRemove(gIntListen_Id);
102 llSetTimerEvent(0); //Stop the timer from being called repeatedly
103 }
104 }

Back to the Best Free Tools in Second Life and OpenSim.