From bbe5681d05d486d86f53d2adf3fa40b136c29df9 Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 20 Jul 2017 20:51:06 +0100
Subject: [PATCH] SL-751 - added test script
 move_in_circle_using_llSetRegionPos.lsl

---
 .../move_in_circle_using_llSetRegionPos.lsl   | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100644 scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl

diff --git a/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl
new file mode 100644
index 00000000000..5303b6f4f5a
--- /dev/null
+++ b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl
@@ -0,0 +1,98 @@
+integer listenHandle; 
+integer verbose;
+integer num_steps = 50;
+float circle_time = 5.0;
+integer circle_step;
+vector circle_pos;
+vector circle_center;
+float circle_radius;
+
+start_circle(vector center, float radius)
+{
+    vector currentPosition = llGetPos();
+    circle_center = center;
+    circle_radius = radius;
+    circle_step = 0;
+    llSetTimerEvent(circle_time/num_steps);
+}
+
+stop_circle()
+{
+    llSetTimerEvent(0);
+    llSetRegionPos(circle_center);
+}
+
+next_circle()
+{
+    float rad = (circle_step * TWO_PI)/num_steps;
+    float x = circle_center.x + llCos(rad)*circle_radius;
+    float y = circle_center.y + llSin(rad)*circle_radius;
+    float z = circle_center.z;
+    llSetRegionPos(<x,y,z>);
+    circle_step = (circle_step+1)%num_steps;
+}
+
+circle_path(vector center, float radius)
+{
+    integer i;
+    integer num_steps = 50;
+    float circle_time = 5.0; // seconds
+    for (i=0; i<num_steps; ++i)
+    {
+        float rad = (i * TWO_PI)/num_steps;
+        float x = center.x + llCos(rad)*radius;
+        float y = center.y + llSin(rad)*radius;
+        float z = center.z;
+        llSetRegionPos(<x,y,z>);
+        llSleep(circle_time/num_steps);
+    }
+}
+
+default
+{
+    state_entry()
+    {
+        llSay(0, "Hello, Avatar!");
+        listenHandle = llListen(-2001,"","","");  
+        verbose = 0;
+    }
+
+    listen(integer channel, string name, key id, string message)
+    {
+        llOwnerSay("got message " + name + " " + (string) id + " " + message);
+        list words = llParseString2List(message,[" "],[]);
+        string command = llList2String(words,0);
+        string option = llList2String(words,1);
+        if (command=="anim")
+        {
+            if (option=="start")
+            {
+                start_circle(llGetPos(), 3.0);
+            }
+            else if (option=="stop")
+            {
+                stop_circle();
+            }
+        }
+        if (command=="verbose")
+        {
+            if (option=="on")
+            {
+                verbose = 1;
+            }
+            else if (option=="off")
+            {
+                verbose = 0;
+            }
+        }
+    }
+
+    timer()
+    {
+        next_circle();
+    }
+}
+
+// Local Variables:
+// shadow-file-name: "$SW_HOME/axon/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl"
+// End:
-- 
GitLab