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 | |

Compass | Dan Medici | Compass_By_Dan_Medici |

Category: Compass

By : Dan Medici

Created: 2010-01-10 Edited: 2010-01-10

Worlds: Second Life

Browse the Zip file

Download all files for Compass_By_Dan_Medici

Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.

Get file # 1. Compass_By_Dan_Medici_1.lsl Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.

12 // Compass By Dan Medici3 //Description: This script finds the cardinal direction that an object is currently pointing towards, and sets it in text above the object that the script is in.45 //Edit: Now fixed to work even when avatar is standing still.67 //How to use: Put inside an object either attached to your avatar or on a moving object.8910111213 default14 {15 state_entry()16 {17 llSetTimerEvent(0.1); // set a timer event for every tenth of a second18 }1920 timer()21 {22 string direction; // this is the variable we will set the text with262728 //Keep in mind the following when reading the following part of this script: when one travels perfectly east at a speed of 1.0, their velocity is <1.0,0,0>. Therefore, if they were traveling west,29 //it would be <-1.0,0,0>. If they were traveling north, it would be <0.0,1.0,0.0>. If they were traveling south, it would be <0.0,-1.0,0.0>. We dont deal with the Z value of the velocity at all30 //because cardinal directions are based on a two-dimensional coordinate plane.31 if((llAbs(x) > llAbs(y)) && (x > 0)) // if the absolute value of X is greater than Y, then we are traveling mostly east or west. If X is positive, then we are traveling east.32 {33 direction="East";34 }35 else if((llAbs(x) > llAbs(y)) && (x < 0)) // if the absolute value of X is greater than Y, then we are traveling mostly east or west. If X is negative, then we are traveling west.36 {3738 direction = "West";39 }40 else if((llAbs(y) > llAbs(x)) && (y > 0)) // if the absolute value of Y is greater than X, then we are traveling mostly north or south. If Y is positive, then we are traveling north.41 {4243 direction = "North";44 }45 else if((llAbs(y) > llAbs(x)) && (y < 0)) // if the absolute value of Y is greater than X, then we are traveling mostly north or south. If Y is negative, then we are traveling south.46 {4748 direction = "South";49 }50 else if((llAbs(y) == llAbs(x)) && (x > 0 && y > 0)) // if the absolute value of Y is equal to X, then we are in an intermediate direction. If both X and Y are positive, then we are traveling nort //heast, because EAST is positive on the X axis and north is positive on the Y axis.51 {5253 direction = "Northeast";54 }55 else if((llAbs(y) == llAbs(x)) && (x < 0 && y > 0)) // if the absolute value of Y is equal to X, then we are in an intermediate direction. If X is negative and Y is positive, then we are traveling //northwest56 {5758 direction = "Northwest";59 }60 else if((llAbs(y) == llAbs(x)) && (x < 0 && y < 0)) // if the absolute value of Y is equal to X, then we are in an intermediate direction. If X is negative and Y is negative, then we are traveling //southwest61 {6263 direction = "Southwest";64 }65 else if((llAbs(y) == llAbs(x)) && (x > 0 && y < 0)) // if the absolute value of Y is equal to X, then we are in an intermediate direction. If X is positive and Y is negative, then we are traveling //southeast66 {6768 direction = "Southeast";69 }70 else // not moving71 {72 direction = "Stationary";73 }74 llSetText(direction, <1,1,1>, 1.0); // set text on the object to what direction we are moving in75 }76 }77 // END //

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