From fb8faa8336ddb795ccd6840259b06a2608350a57 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Mon, 12 Jan 2009 18:00:46 +0000 Subject: * Apply http://opensimulator.org/mantis/view.php?id=2913 * Add the KanEd scripts to the standard library * Thanks Fly-Man- --- bin/assets/ScriptsAssetSet/KanEd-Test16.lsl | 66 +++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 bin/assets/ScriptsAssetSet/KanEd-Test16.lsl (limited to 'bin/assets/ScriptsAssetSet/KanEd-Test16.lsl') 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 @@ +// This is a script designed to orbit its owner. +vector startPos; +vector curPos; + +vector offset; // offset from Agent +integer iteration; +float rotationRate; // degrees of rotation per iteration +float sensorInterval; // seconds between sensor scan. + +default +{ + state_entry() + { + llOwnerSay( "Hello, Avatar! Touch to start orbiting." ); + llSetStatus( 1, FALSE ); // turn Physics off. + offset = < 2, 2, 1 >; + iteration = 0; + rotationRate = .5; + sensorInterval = .3; + } + + touch_start(integer total_number) + { + startPos = llGetPos(); + curPos = startPos; + + llSleep( .1 ); + + key id = llGetOwner(); + llSensorRepeat( "", id, AGENT, 96, PI, sensorInterval ); + } + + sensor(integer total_number) + { + iteration++; + + if( iteration > 300 ) + { + llResetScript(); + } + + if( llDetectedOwner( 0 ) == llGetOwner() ) + { // the detected Agent is my owner. + vector position = llDetectedPos(0); // find Owner position. + + // calculate next object position relative both to the Owner's + // position and the current time interval counter. That is, + // use the iteration counter to define a rotation, multiply + // the rotation by the constant offset to get a rotated offset + // vector, and add that rotated offset to the current position + // to defne the new position. + + float degreeRotation = llRound( rotationRate * iteration ) % 360; + rotation Rotation = + llEuler2Rot( < 0, 0, degreeRotation * DEG_TO_RAD > ); + vector rotatedOffset = offset * Rotation; + position += rotatedOffset; + + // change the location of the object and save the current (rotated) + // offset for use during the next iteration. + llSetPos( position ); + offset = rotatedOffset; + } + } +} + -- cgit v1.1