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

L96kite

L9.06-kite.lsl

Category: Kites
By : Dana Moore
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for L96kite
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. L96kite_1.lsl
1
2 // Copyright (c) 2008, Scripting Your World
3 // All rights reserved.
4 //
5 // Scripting Your World
6 // By Dana Moore, Michael Thome, and Dr. Karen Zita Haigh
7 // http://syw.fabulo.us
8 // http://www.amazon.com/Scripting-Your-World-Official-Second/dp/0470339837/
9 //
10 // You are permitted to use, share, and adapt this code under the
11 // terms of the Creative Commons Public License described in full
12 // at http://creativecommons.org/licenses/by/3.0/legalcode.
13 // That means you must keep the credits, do nothing to damage our
14 // reputation, and do not suggest that we endorse you or your work.
15
16 // Listing 9.6: The Flying Kite
17 string SPOOL = "KiteSpool";
18 string SPOOL_REZZED = "SpoolRezzed";
19 float SENSOR_INTERVAL = 5.0;
20 float MAX_SPOOL_DIST = 50.0;
21 float MAX_WIND_STRENGTH = 0.75; // ratio of VecMag(wind) to string len
22
23 key gSpoolID;
24 vector gStartPos;
25 rotation gStartRot;
26 float gSpoolDistance = 5.0; // could listen to Chat to change
27 integer gInitialKitePosHandle;
28
29 default {
30 state_entry() {
32 llSleep(0.1);
33 gStartPos = llGetPos();
34 gStartRot = llGetRot();
35 vector targetPos = gStartPos + <0,0,2>; // float in the air
36 llMoveToTarget( targetPos, 2.0 );
37 gInitialKitePosHandle = llTarget( targetPos, 1.0 );
38 }
39 on_rez(integer param) {
41 }
42 at_target( integer targetHandle, vector targPos, vector currPos ) {
43 if(targetHandle == gInitialKitePosHandle) {
44 llRezObject(SPOOL,gStartPos, ZERO_VECTOR,ZERO_ROTATION, 1);
45 llTargetRemove( gInitialKitePosHandle );
46 }
47 }
48 object_rez(key id) {
49 // message to other script in same prim
50 llMessageLinked(llGetLinkNumber(), 0, SPOOL_REZZED, id);
51 gSpoolID = id;
52 llSensorRepeat(SPOOL, id, PASSIVE|ACTIVE, MAX_SPOOL_DIST,
53 TWO_PI, SENSOR_INTERVAL);
54 }
55
56 no_sensor() {
57 llSay(0,"The spool has vanished. Returning home.");
60 llSetPos(gStartPos); // or use moveTo() from Listing 2.4
61 llSetRot(gStartRot);
63 }
64 sensor(integer num) {
65 vector spoolPos = llDetectedPos(0);
66 vector windDir = llWind( spoolPos );
67 windDir.z = 0;
68 float windStrength = llVecMag(windDir);
69 if(windStrength > (gSpoolDistance * MAX_WIND_STRENGTH)) {
70 windStrength = gSpoolDistance * MAX_WIND_STRENGTH;
71 }
72 float theta = llAsin( windStrength / gSpoolDistance );
73 float height = gSpoolDistance * llCos( theta );
74 vector posOffset = <windDir.x, windDir.y, height>;
75
76 llMoveToTarget( spoolPos+posOffset, SENSOR_INTERVAL );
77 llLookAt( spoolPos, 1.0, 1.0 );
78 }
79 }
80 // END //

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