From 2af5332e46b3917d6dce211e576a92d04c3eda8b Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 30 Jun 2017 21:59:39 +0100 Subject: Added cycle_object_animations.lsl. Also change to test.cpp to see if it affects a g++ internal compiler error. --- scripts/testing/lsl/cycle_object_animations.lsl | 53 +++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 scripts/testing/lsl/cycle_object_animations.lsl (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/cycle_object_animations.lsl b/scripts/testing/lsl/cycle_object_animations.lsl new file mode 100644 index 0000000000..95fa99a191 --- /dev/null +++ b/scripts/testing/lsl/cycle_object_animations.lsl @@ -0,0 +1,53 @@ +cycle_animations() +{ + list AnimationList; + integer count = llGetInventoryNumber(INVENTORY_ANIMATION); + string ItemName; + string NowPlaying; + while (count--) + { + ItemName = llGetInventoryName(INVENTORY_ANIMATION, count); + if (NowPlaying != "") + { + llSay(0, "Stopping " + NowPlaying); + llStopObjectAnimation(NowPlaying); + } + llSay(0, "Starting " + ItemName); + llStartObjectAnimation(ItemName); + NowPlaying = ItemName; + llSleep(10); + } + if (NowPlaying != "") + { + llSay(0, "Stopping " + NowPlaying); + llStopObjectAnimation(NowPlaying); + llSleep(10); + } +} + +default +{ + state_entry() + { + llSay(0, "Animated Object here"); + } + + touch_start(integer total_number) + { + llSay(0, "Touch started."); + while (1) + { + cycle_animations(); + } + + } + + touch_end(integer total_number) + { + llSay(0, "Touch ended."); + } +} + +// Local Variables: +// shadow-file-name: "$SW_HOME/axon/scripts/testing/lsl/cycle_object_animations.lsl" +// End: -- cgit v1.2.3 From f55667397e75991348fa25b6ad581a36de99acf0 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 6 Jul 2017 01:25:10 +0100 Subject: SL-722 - handle per-object animation requests, combine for control avatar animation state. --- scripts/testing/lsl/cycle_object_animations.lsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/cycle_object_animations.lsl b/scripts/testing/lsl/cycle_object_animations.lsl index 95fa99a191..79c8ff4151 100644 --- a/scripts/testing/lsl/cycle_object_animations.lsl +++ b/scripts/testing/lsl/cycle_object_animations.lsl @@ -9,17 +9,17 @@ cycle_animations() ItemName = llGetInventoryName(INVENTORY_ANIMATION, count); if (NowPlaying != "") { - llSay(0, "Stopping " + NowPlaying); + //llSay(0, "Stopping " + NowPlaying); llStopObjectAnimation(NowPlaying); } - llSay(0, "Starting " + ItemName); + //llSay(0, "Starting " + ItemName); llStartObjectAnimation(ItemName); NowPlaying = ItemName; llSleep(10); } if (NowPlaying != "") { - llSay(0, "Stopping " + NowPlaying); + //llSay(0, "Stopping " + NowPlaying); llStopObjectAnimation(NowPlaying); llSleep(10); } -- cgit v1.2.3 From 41f7f7a68ee3d9b3eee55437ef0ffcd1d0277227 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 14 Jul 2017 22:18:53 +0100 Subject: SL-751 - lsl scripts for control of animated objects within a region --- scripts/testing/lsl/axon_test_region_driver.lsl | 54 ++++++++++++ scripts/testing/lsl/cycle_object_animations.lsl | 105 +++++++++++++++++++----- 2 files changed, 139 insertions(+), 20 deletions(-) create mode 100644 scripts/testing/lsl/axon_test_region_driver.lsl (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/axon_test_region_driver.lsl b/scripts/testing/lsl/axon_test_region_driver.lsl new file mode 100644 index 0000000000..dfcbb9871a --- /dev/null +++ b/scripts/testing/lsl/axon_test_region_driver.lsl @@ -0,0 +1,54 @@ +list buttons = ["anim start", "anim stop", " ", "verbose on", "verbose off", " "]; +string dialogInfo = "\nPlease make a choice."; + +key ToucherID; +integer dialogChannel; +integer listenHandle; +integer commandChannel; + +default +{ + state_entry() + { + dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) ); + commandChannel = -2001; + } + + touch_start(integer num_detected) + { + ToucherID = llDetectedKey(0); + llListenRemove(listenHandle); + listenHandle = llListen(dialogChannel, "", ToucherID, ""); + llDialog(ToucherID, dialogInfo, buttons, dialogChannel); + llSetTimerEvent(60.0); // Here we set a time limit for responses + } + + listen(integer channel, string name, key id, string message) + { + if (message == "-") + { + llDialog(ToucherID, dialogInfo, buttons, dialogChannel); + return; + } + + llListenRemove(listenHandle); + // stop timer since the menu was clicked + llSetTimerEvent(0); + + llOwnerSay("Sending message " + message + " on channel " + (string)commandChannel); + llRegionSay(commandChannel, message); + } + + timer() + { + // stop timer + llSetTimerEvent(0); + + llListenRemove(listenHandle); + llWhisper(0, "Sorry. You snooze; you lose."); + } +} + +// Local Variables: +// shadow-file-name: "$SW_HOME/axon/scripts/testing/lsl/axon_test_region_driver.lsl" +// End: diff --git a/scripts/testing/lsl/cycle_object_animations.lsl b/scripts/testing/lsl/cycle_object_animations.lsl index 79c8ff4151..e7a378889a 100644 --- a/scripts/testing/lsl/cycle_object_animations.lsl +++ b/scripts/testing/lsl/cycle_object_animations.lsl @@ -1,50 +1,115 @@ -cycle_animations() +integer listenHandle; +integer verbose; +integer current_animation_number; +string NowPlaying; + +say_if_verbose(integer channel, string message) +{ + if (verbose) + { + llSay(0, message); + } +} + +stop_all_animations() { - list AnimationList; integer count = llGetInventoryNumber(INVENTORY_ANIMATION); string ItemName; string NowPlaying; while (count--) { ItemName = llGetInventoryName(INVENTORY_ANIMATION, count); - if (NowPlaying != "") - { - //llSay(0, "Stopping " + NowPlaying); - llStopObjectAnimation(NowPlaying); - } - //llSay(0, "Starting " + ItemName); - llStartObjectAnimation(ItemName); - NowPlaying = ItemName; - llSleep(10); + say_if_verbose(0, "Stopping " + ItemName); + llStopObjectAnimation(ItemName); } +} + +start_cycle_animations() +{ + current_animation_number = llGetInventoryNumber(INVENTORY_ANIMATION); + next_animation(); // Do first iteration without waiting for timer + llSetTimerEvent(5.0); +} + +next_animation() +{ + string ItemName; if (NowPlaying != "") { - //llSay(0, "Stopping " + NowPlaying); + say_if_verbose(0, "Stopping " + NowPlaying); llStopObjectAnimation(NowPlaying); - llSleep(10); } + if (current_animation_number--) + { + ItemName = llGetInventoryName(INVENTORY_ANIMATION, current_animation_number); + say_if_verbose(0, "Starting " + ItemName); + llStartObjectAnimation(ItemName); + NowPlaying = ItemName; + } + else + { + // Start again at the top + current_animation_number = llGetInventoryNumber(INVENTORY_ANIMATION); + } +} + +stop_cycle_animations() +{ + llSetTimerEvent(0); } default { state_entry() { - llSay(0, "Animated Object here"); + say_if_verbose(0, "Animated Object here"); + listenHandle = llListen(-2001,"","",""); + verbose = 0; + + stop_all_animations(); } - touch_start(integer total_number) + listen(integer channel, string name, key id, string message) { - llSay(0, "Touch started."); - while (1) + llOwnerSay("got message " + name + " " + (string) id + " " + message); + list words = llParseString2List(message,[" "],[]); + string command = llList2String(words,0); + string option = llList2String(words,1); + if (command=="anim") + { + stop_all_animations(); + if (option=="start") + { + start_cycle_animations(); + } + else if (option=="stop") + { + stop_cycle_animations(); + } + } + if (command=="verbose") { - cycle_animations(); + if (option=="on") + { + verbose = 1; + } + else if (option=="off") + { + verbose = 0; + } } + } + timer() + { + say_if_verbose(0, "timer triggered"); + next_animation(); } - touch_end(integer total_number) + touch_start(integer total_number) { - llSay(0, "Touch ended."); + say_if_verbose(0, "Touch started."); + start_cycle_animations(); } } -- cgit v1.2.3 From bbe5681d05d486d86f53d2adf3fa40b136c29df9 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 20 Jul 2017 20:51:06 +0100 Subject: SL-751 - added test script move_in_circle_using_llSetRegionPos.lsl --- .../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 (limited to 'scripts/testing/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 0000000000..5303b6f4f5 --- /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(); + 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); + 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: -- cgit v1.2.3 From 30880e062afa0671b166f161ae7c109bfd37d38f Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 21 Jul 2017 20:01:40 +0100 Subject: SL-751, SL-691 - test lsl scripts update, better syncing between skeleton and drawable --- scripts/testing/lsl/axon_test_region_driver.lsl | 8 ++--- .../lsl/move_in_circle_using_llSetRegionPos.lsl | 39 +++++++++++----------- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/axon_test_region_driver.lsl b/scripts/testing/lsl/axon_test_region_driver.lsl index dfcbb9871a..dcf146a9cf 100644 --- a/scripts/testing/lsl/axon_test_region_driver.lsl +++ b/scripts/testing/lsl/axon_test_region_driver.lsl @@ -1,4 +1,4 @@ -list buttons = ["anim start", "anim stop", " ", "verbose on", "verbose off", " "]; +list buttons = ["anim start", "anim stop", "step", "verbose on", "verbose off", " "]; string dialogInfo = "\nPlease make a choice."; key ToucherID; @@ -20,7 +20,7 @@ default llListenRemove(listenHandle); listenHandle = llListen(dialogChannel, "", ToucherID, ""); llDialog(ToucherID, dialogInfo, buttons, dialogChannel); - llSetTimerEvent(60.0); // Here we set a time limit for responses + //llSetTimerEvent(60.0); // Here we set a time limit for responses } listen(integer channel, string name, key id, string message) @@ -35,7 +35,7 @@ default // stop timer since the menu was clicked llSetTimerEvent(0); - llOwnerSay("Sending message " + message + " on channel " + (string)commandChannel); + //llOwnerSay("Sending message " + message + " on channel " + (string)commandChannel); llRegionSay(commandChannel, message); } @@ -45,7 +45,7 @@ default llSetTimerEvent(0); llListenRemove(listenHandle); - llWhisper(0, "Sorry. You snooze; you lose."); + //llWhisper(0, "Sorry. You snooze; you lose."); } } diff --git a/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl index 5303b6f4f5..fa12ab0588 100644 --- a/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl +++ b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl @@ -1,6 +1,6 @@ integer listenHandle; integer verbose; -integer num_steps = 50; +integer num_steps = 12; float circle_time = 5.0; integer circle_step; vector circle_pos; @@ -14,12 +14,21 @@ start_circle(vector center, float radius) circle_radius = radius; circle_step = 0; llSetTimerEvent(circle_time/num_steps); + llTargetOmega(<0.0, 0.0, 1.0>, TWO_PI/circle_time, 1.0); } stop_circle() { llSetTimerEvent(0); - llSetRegionPos(circle_center); + llTargetOmega(<0.0, 0.0, 1.0>, TWO_PI/circle_time, 0.0); + integer i; + for (i=0; i<10; i++) + { + vector new_pos = circle_center; + new_pos.x += llFrand(0.01); + llSetRegionPos(new_pos); + llSleep(0.1); + } } next_circle() @@ -32,34 +41,19 @@ next_circle() 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); - llSleep(circle_time/num_steps); - } -} - default { state_entry() { - llSay(0, "Hello, Avatar!"); + //llSay(0, "Hello, Avatar!"); listenHandle = llListen(-2001,"","",""); verbose = 0; + circle_center = llGetPos(); } listen(integer channel, string name, key id, string message) { - llOwnerSay("got message " + name + " " + (string) id + " " + message); + //llOwnerSay("got message " + name + " " + (string) id + " " + message); list words = llParseString2List(message,[" "],[]); string command = llList2String(words,0); string option = llList2String(words,1); @@ -85,6 +79,11 @@ default verbose = 0; } } + if (command=="step") + { + llSetTimerEvent(0); + next_circle(); + } } timer() -- cgit v1.2.3 From 22c8efc2ce8cac2056b73c504b95a9413fff8818 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 26 Jul 2017 18:56:18 +0100 Subject: SL-731, SL-751 - added debug option DebugAnimatedObjects, updated LSL test script --- scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl index fa12ab0588..cc5b899b67 100644 --- a/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl +++ b/scripts/testing/lsl/move_in_circle_using_llSetRegionPos.lsl @@ -21,14 +21,7 @@ stop_circle() { llSetTimerEvent(0); llTargetOmega(<0.0, 0.0, 1.0>, TWO_PI/circle_time, 0.0); - integer i; - for (i=0; i<10; i++) - { - vector new_pos = circle_center; - new_pos.x += llFrand(0.01); - llSetRegionPos(new_pos); - llSleep(0.1); - } + llSetRegionPos(circle_center); } next_circle() -- cgit v1.2.3 From 936ccff59f2045f5747a0730570784608f39a7b4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 31 Aug 2017 16:48:26 +0100 Subject: SL-751 - updated lsl test scripts with bug fix, added a version that uses the new command llGetObjectAnimationNames() --- scripts/testing/lsl/cycle_object_animations.lsl | 4 +- scripts/testing/lsl/cycle_object_animations_v2.lsl | 133 +++++++++++++++++++++ 2 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 scripts/testing/lsl/cycle_object_animations_v2.lsl (limited to 'scripts/testing/lsl') diff --git a/scripts/testing/lsl/cycle_object_animations.lsl b/scripts/testing/lsl/cycle_object_animations.lsl index e7a378889a..46910e3656 100644 --- a/scripts/testing/lsl/cycle_object_animations.lsl +++ b/scripts/testing/lsl/cycle_object_animations.lsl @@ -7,7 +7,7 @@ say_if_verbose(integer channel, string message) { if (verbose) { - llSay(0, message); + llSay(channel, message); } } @@ -71,7 +71,7 @@ default listen(integer channel, string name, key id, string message) { - llOwnerSay("got message " + name + " " + (string) id + " " + message); + //llOwnerSay("got message " + name + " " + (string) id + " " + message); list words = llParseString2List(message,[" "],[]); string command = llList2String(words,0); string option = llList2String(words,1); diff --git a/scripts/testing/lsl/cycle_object_animations_v2.lsl b/scripts/testing/lsl/cycle_object_animations_v2.lsl new file mode 100644 index 0000000000..60879fcce2 --- /dev/null +++ b/scripts/testing/lsl/cycle_object_animations_v2.lsl @@ -0,0 +1,133 @@ +integer listenHandle; +integer verbose; +integer current_animation_number; +string NowPlaying; + +say_if_verbose(integer channel, string message) +{ + if (verbose) + { + llSay(channel, message); + } +} + +stop_all_animations() +{ + list curr_anims = llGetObjectAnimationNames(); + say_if_verbose(0,"stopping all, curr_anims are " + (string) curr_anims); + integer length = llGetListLength(curr_anims); + integer index = 0; + while (index < length) + { + string anim = llList2String(curr_anims, index); + say_if_verbose(0, "Stopping " + anim); + llStopObjectAnimation(anim); + // This check isn't really needed, just included to demonstrate is_animation_running() + if (is_animation_running(anim)) + { + say_if_verbose(0, "ERROR - failed to stop " + anim + "!"); + } + ++index; + } +} + +integer is_animation_running(string anim) +{ + list curr_anims = llGetObjectAnimationNames(); + return ~llListFindList(curr_anims, (list)anim); +} + +start_cycle_animations() +{ + current_animation_number = llGetInventoryNumber(INVENTORY_ANIMATION); + next_animation(); // Do first iteration without waiting for timer + llSetTimerEvent(5.0); +} + +next_animation() +{ + string ItemName; + if (NowPlaying != "") + { + say_if_verbose(0, "Stopping " + NowPlaying); + llStopObjectAnimation(NowPlaying); + } + if (current_animation_number--) + { + ItemName = llGetInventoryName(INVENTORY_ANIMATION, current_animation_number); + say_if_verbose(0, "Starting " + ItemName); + llStartObjectAnimation(ItemName); + key anim_id = llGetInventoryKey(ItemName); + say_if_verbose(0, "Started item " + ItemName + " inv key " + (string) anim_id); + NowPlaying = ItemName; + } + else + { + // Start again at the top + current_animation_number = llGetInventoryNumber(INVENTORY_ANIMATION); + } +} + +stop_cycle_animations() +{ + llSetTimerEvent(0); +} + +default +{ + state_entry() + { + say_if_verbose(0, "Animated Object here"); + listenHandle = llListen(-2001,"","",""); + verbose = 0; + + stop_all_animations(); + } + + 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") + { + stop_all_animations(); + if (option=="start") + { + start_cycle_animations(); + } + else if (option=="stop") + { + stop_cycle_animations(); + } + } + if (command=="verbose") + { + if (option=="on") + { + verbose = 1; + } + else if (option=="off") + { + verbose = 0; + } + } + } + + timer() + { + say_if_verbose(0, "timer triggered"); + next_animation(); + } + + touch_start(integer total_number) + { + say_if_verbose(0, "Touch started."); + start_cycle_animations(); + } +} + +// Local Variables: +// shadow-file-name: "$SW_HOME/axon/scripts/testing/lsl/cycle_object_animations_v2.lsl" +// End: -- cgit v1.2.3