diff options
Diffstat (limited to 'bin/assets/ScriptsAssetSet/KanEd-Test16.lsl')
-rw-r--r-- | bin/assets/ScriptsAssetSet/KanEd-Test16.lsl | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/bin/assets/ScriptsAssetSet/KanEd-Test16.lsl b/bin/assets/ScriptsAssetSet/KanEd-Test16.lsl new file mode 100644 index 0000000..536ff19 --- /dev/null +++ b/bin/assets/ScriptsAssetSet/KanEd-Test16.lsl | |||
@@ -0,0 +1,66 @@ | |||
1 | // This is a script designed to orbit its owner. | ||
2 | vector startPos; | ||
3 | vector curPos; | ||
4 | |||
5 | vector offset; // offset from Agent | ||
6 | integer iteration; | ||
7 | float rotationRate; // degrees of rotation per iteration | ||
8 | float sensorInterval; // seconds between sensor scan. | ||
9 | |||
10 | default | ||
11 | { | ||
12 | state_entry() | ||
13 | { | ||
14 | llOwnerSay( "Hello, Avatar! Touch to start orbiting." ); | ||
15 | llSetStatus( 1, FALSE ); // turn Physics off. | ||
16 | offset = < 2, 2, 1 >; | ||
17 | iteration = 0; | ||
18 | rotationRate = .5; | ||
19 | sensorInterval = .3; | ||
20 | } | ||
21 | |||
22 | touch_start(integer total_number) | ||
23 | { | ||
24 | startPos = llGetPos(); | ||
25 | curPos = startPos; | ||
26 | |||
27 | llSleep( .1 ); | ||
28 | |||
29 | key id = llGetOwner(); | ||
30 | llSensorRepeat( "", id, AGENT, 96, PI, sensorInterval ); | ||
31 | } | ||
32 | |||
33 | sensor(integer total_number) | ||
34 | { | ||
35 | iteration++; | ||
36 | |||
37 | if( iteration > 300 ) | ||
38 | { | ||
39 | llResetScript(); | ||
40 | } | ||
41 | |||
42 | if( llDetectedOwner( 0 ) == llGetOwner() ) | ||
43 | { // the detected Agent is my owner. | ||
44 | vector position = llDetectedPos(0); // find Owner position. | ||
45 | |||
46 | // calculate next object position relative both to the Owner's | ||
47 | // position and the current time interval counter. That is, | ||
48 | // use the iteration counter to define a rotation, multiply | ||
49 | // the rotation by the constant offset to get a rotated offset | ||
50 | // vector, and add that rotated offset to the current position | ||
51 | // to defne the new position. | ||
52 | |||
53 | float degreeRotation = llRound( rotationRate * iteration ) % 360; | ||
54 | rotation Rotation = | ||
55 | llEuler2Rot( < 0, 0, degreeRotation * DEG_TO_RAD > ); | ||
56 | vector rotatedOffset = offset * Rotation; | ||
57 | position += rotatedOffset; | ||
58 | |||
59 | // change the location of the object and save the current (rotated) | ||
60 | // offset for use during the next iteration. | ||
61 | llSetPos( position ); | ||
62 | offset = rotatedOffset; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | |||