summaryrefslogtreecommitdiff
path: root/scripts/testing/lsl/cycle_object_animations.lsl
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2018-11-14 15:22:47 -0800
committerGraham Linden <graham@lindenlab.com>2018-11-14 15:22:47 -0800
commitaa0115053aaa28de1c472410931c57b3e43b72a7 (patch)
tree9a8ba45529cb125a2ae5cd4672b3fd093af9b45c /scripts/testing/lsl/cycle_object_animations.lsl
parent4662ba8a2693780198d555a49a00cfafba838d41 (diff)
parent1d022e86c84039f88c531e91ce857666acd224a1 (diff)
Merge
Diffstat (limited to 'scripts/testing/lsl/cycle_object_animations.lsl')
-rw-r--r--scripts/testing/lsl/cycle_object_animations.lsl118
1 files changed, 118 insertions, 0 deletions
diff --git a/scripts/testing/lsl/cycle_object_animations.lsl b/scripts/testing/lsl/cycle_object_animations.lsl
new file mode 100644
index 0000000000..46910e3656
--- /dev/null
+++ b/scripts/testing/lsl/cycle_object_animations.lsl
@@ -0,0 +1,118 @@
+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()
+{
+ integer count = llGetInventoryNumber(INVENTORY_ANIMATION);
+ string ItemName;
+ string NowPlaying;
+ while (count--)
+ {
+ ItemName = llGetInventoryName(INVENTORY_ANIMATION, count);
+ 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 != "")
+ {
+ 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);
+ 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.lsl"
+// End: