Automatic_GIF_to_SL_script player.lsl 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // Put any texture converted by gif_2_SL_animation_v0.6.exe into a prim with this script to get it to play back automatically as a movie
  2. //Effect parameters: (can be put in list together, to make animation have all of said effects)
  3. //LOOP - loops the animation
  4. //SMOOTH - plays animation smoothly
  5. //REVERSE - plays animation in reverse
  6. //PING_PONG - plays animation in one direction, then cycles in the opposite direction
  7. list effects = [LOOP]; // LOOP for GIF89 movies
  8. //Movement parameters (choose one):
  9. //ROTATE - Rotates the texture
  10. //SCALE - Scales the texture
  11. //Set movement to 0 to slide animation in the X direction, without any special movement.
  12. integer movement = 0;
  13. integer face = ALL_SIDES; //Number representing the side to activate the animation on.
  14. integer sideX = 1; //Represents how many horizontal images (frames) are contained in your texture.
  15. integer sideY = 1; //Same as sideX, except represents vertical images (frames).
  16. float start = 0.0; //Frame to start animation on. (0 to start at the first frame of the texture)
  17. float length = 0.0; //Number of frames to animate, set to 0 to animate all frames.
  18. float speed = 10.0; //Frames per second to play.
  19. list choices; // a list of all texture names
  20. // from the menu system http://wiki.secondlife.com/wiki/SimpleDialogMenuSystem
  21. integer N_DIALOG_CHOICES;
  22. integer MAX_DIALOG_CHOICES_PER_PG = 8; // if not offering back button, increase this to 9
  23. string PREV_PG_DIALOG_PREFIX = "< Page ";
  24. string NEXT_PG_DIALOG_PREFIX = "> Page ";
  25. string DIALOG_DONE_BTN = "Done";
  26. string DIALOG_BACK_BTN = "<< Back";
  27. integer pageNum;
  28. list DIALOG_CHOICES;
  29. giveDialog(key ID, integer pageNum) {
  30. list buttons;
  31. integer firstChoice;
  32. integer lastChoice;
  33. integer prevPage;
  34. integer nextPage;
  35. string OnePage;
  36. CancelListen();
  37. menuChannel = llCeil(llFrand(1000000) + 11000000);
  38. listen_id = llListen(menuChannel,"","","");
  39. mode = FALSE;
  40. llSetTimerEvent(60);
  41. N_DIALOG_CHOICES = llGetListLength(DIALOG_CHOICES);
  42. if (N_DIALOG_CHOICES <= 10) {
  43. buttons = DIALOG_CHOICES;
  44. OnePage = "Yes";
  45. }
  46. else {
  47. integer nPages = (N_DIALOG_CHOICES+MAX_DIALOG_CHOICES_PER_PG-1)/MAX_DIALOG_CHOICES_PER_PG;
  48. if (pageNum < 1 || pageNum > nPages) {
  49. pageNum = 1;
  50. }
  51. firstChoice = (pageNum-1)*MAX_DIALOG_CHOICES_PER_PG;
  52. lastChoice = firstChoice+MAX_DIALOG_CHOICES_PER_PG-1;
  53. if (lastChoice >= N_DIALOG_CHOICES) {
  54. lastChoice = N_DIALOG_CHOICES;
  55. }
  56. if (pageNum <= 1) {
  57. prevPage = nPages;
  58. nextPage = 2;
  59. }
  60. else if (pageNum >= nPages) {
  61. prevPage = nPages-1;
  62. nextPage = 1;
  63. }
  64. else {
  65. prevPage = pageNum-1;
  66. nextPage = pageNum+1;
  67. }
  68. buttons = llList2List(DIALOG_CHOICES, firstChoice, lastChoice);
  69. }
  70. // FYI, this puts the navigation button row first, so it is always at the bottom of the dialog
  71. list buttons01 = llList2List(buttons, 0, 2);
  72. list buttons02 = llList2List(buttons, 3, 5);
  73. list buttons03 = llList2List(buttons, 6, 8);
  74. list buttons04;
  75. if (OnePage == "Yes") {
  76. buttons04 = llList2List(buttons, 9, 11);
  77. }
  78. buttons = buttons04 + buttons03 + buttons02 + buttons01;
  79. if (OnePage == "Yes") {
  80. buttons = [ DIALOG_DONE_BTN, DIALOG_BACK_BTN ]+ buttons;
  81. //omit DIALOG_BACK_BTN in line above if not offering
  82. }
  83. else {
  84. buttons = [
  85. PREV_PG_DIALOG_PREFIX + (string)prevPage,
  86. DIALOG_BACK_BTN, NEXT_PG_DIALOG_PREFIX+(string)nextPage, DIALOG_DONE_BTN
  87. ]+buttons;
  88. //omit DIALOG_BACK_BTN in line above if not offering
  89. }
  90. llDialog(ID, "Page "+(string)pageNum+"\nChoose one:", buttons, menuChannel);
  91. }
  92. CancelListen() {
  93. llListenRemove(listen_id);
  94. llSetTimerEvent(3600);
  95. mode = TRUE;
  96. }
  97. initAnim() //Call this when you want to change something in the texture animation.
  98. {
  99. integer effectBits;
  100. integer i;
  101. for(i = 0; i < llGetListLength(effects); i++)
  102. {
  103. effectBits = (effectBits | llList2Integer(effects,i));
  104. }
  105. integer params = (effectBits|movement);
  106. llSetTextureAnim(ANIM_ON|params,face,sideX,sideY, start,length,speed);
  107. }
  108. fetch(string texture)
  109. {
  110. integer i;
  111. integer j = llGetInventoryNumber(INVENTORY_TEXTURE);
  112. for (i = 0; i < j; i ++)
  113. {
  114. string texture = llGetInventoryName(INVENTORY_TEXTURE,i);
  115. list data = llParseString2List(texture,[";"],[]);
  116. string name = llList2String(data,0);
  117. if (name == texture) {
  118. string X = llList2String(data,1);
  119. string Y = llList2String(data,2);
  120. string Z = llList2String(data,3);
  121. llSetTexture(texture,ALL_SIDES);
  122. sideX = (integer) X;
  123. sideY = (integer) Y;
  124. speed = (float) Z;
  125. llOwnerSay("X=" + X + " Y=" + Y + " Z = " + (string) Z);
  126. if (speed) {
  127. initAnim();
  128. }
  129. }
  130. }
  131. }
  132. // Make a list of all bare names for the dialog
  133. fetchAll()
  134. {
  135. choices = [];
  136. integer i;
  137. integer j = llGetInventoryNumber(INVENTORY_TEXTURE);
  138. for (i = 0; i < j; i ++)
  139. {
  140. string texture = llGetInventoryName(INVENTORY_TEXTURE,i);
  141. list data = llParseString2List(texture,[";"],[]);
  142. string name = llList2String(data,0);
  143. choices ++ name;
  144. }
  145. }
  146. default
  147. {
  148. state_entry()
  149. {
  150. }
  151. touch_start(integer who)
  152. {
  153. if (llDetectedKey(0) == llGetOwner() )
  154. {
  155. DIALOG_CHOICES = getImages();
  156. pageNum = 1;
  157. fetchAll();
  158. giveDialog(llGetOwner(), pageNum);
  159. }
  160. }
  161. listen(integer channel, string name, key id, string message)
  162. {
  163. integer where ;
  164. if (message == "-")
  165. {
  166. giveDialog(llGetOwner(), pageNum);
  167. }
  168. else if ( message == DIALOG_DONE_BTN)
  169. {
  170. CancelListen();
  171. return;
  172. }
  173. else if (message == DIALOG_BACK_BTN)
  174. {
  175. pageNum = 1;
  176. DIALOG_CHOICES = choices;
  177. giveDialog(llGetOwner(), pageNum);
  178. }
  179. else if (llSubStringIndex(message, PREV_PG_DIALOG_PREFIX) == 0)
  180. {
  181. pageNum = (integer)llGetSubString(message, llStringLength(PREV_PG_DIALOG_PREFIX), -1);
  182. giveDialog(llGetOwner(), pageNum);
  183. }
  184. else if (llSubStringIndex(message, NEXT_PG_DIALOG_PREFIX) == 0)
  185. {
  186. pageNum = (integer)llGetSubString(message, llStringLength(NEXT_PG_DIALOG_PREFIX), -1);
  187. giveDialog(llGetOwner(), pageNum);
  188. } else { //this is the section where you do stuff
  189. CancelListen();
  190. where = llListFindList(choices,[message]);
  191. if (where >= 0)
  192. {
  193. fetch(message);
  194. giveDialog(llGetOwner(), pageNum);
  195. }
  196. }
  197. }
  198. }
  199. }