Circularrezzer.lsl

This is the rezzer script described on Using NewtonPhysics that will rez out two stars orbiting in a circle. Read the instructions on Using NewtonPhysics to make it work.

// Listens on channel 1 for instructions //  "rez" -- rez the stars //  "go"  -- tell stars to apply initial velocity and go //   "stop" -- turns stars unphysical //  "start" -- turns stars physical //  "die" -- tells stars to die

integer chan = 3117;

// Distance between the stars float r = 2.;

// mass of each star float m = 1.0;

// *************** // internal variables

list starpos; list starvel;

default {   state_entry {       llListen(chan, "", "", ""); llListen(1, "", "", ""); }

listen(integer chan, string name, key id, string msg) {       list params = llParseString2List(msg, [" "], []); string command = llList2String(params, 0); integer num = 0; if (llGetListLength(params) > 1) num = llList2Integer(params, 1); if (command == "Hello" && num > 0 && num <= 2) {           // llSay(0, "Got Hello from star " + (string)num); llSay(chan, "pos " + (string)num + " " + llList2String(starpos, num)); llSay(0, "Telling star " + (string)num + " to have initvel " + llList2String(starvel, num)); llSay(chan, "initvel " + (string)num + " " + llList2String(starvel, num)); }       else if (command == "rez") {           starpos = ["junk"]; starvel = ["junk"];

starpos += [llGetPos + ]; starvel += [<0., llSqrt(m/(2.*r)), 0.>]; llRezObject("Star", llGetPos, ZERO_VECTOR, ZERO_ROTATION, 1); starpos += [llGetPos + <-r/2., 0., 0.>]; starvel += [<0., -llSqrt(m/(2.*r)), 0.>]; llRezObject("Star", llGetPos, ZERO_VECTOR, ZERO_ROTATION, 2); }       else if (command == "go") {           llRegionSay(3117, "go"); }       else if (command == "stop") {           llRegionSay(3117, "stop"); }       else if (command == "start") {           llRegionSay(3117, "start"); }       else if (command == "die") {           llRegionSay(3117, "die"); }   }       }