Presentation Add On.lsl 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // :SHOW:
  2. // :CATEGORY:NPC
  3. // :NAME:PMAC
  4. // :AUTHOR:Aine Caoimhe
  5. // :KEYWORDS:
  6. // :CREATED:2015-11-24 20:39:02
  7. // :EDITED:2015-11-24 19:39:02
  8. // :ID:1095
  9. // :NUM:1879
  10. // :REV:1.1
  11. // :WORLD:OpenSim
  12. // :DESCRIPTION:
  13. // PARAMOUR MULTI-ANIMATION CONTROLLER (PMAC) v1.02(OSSL)
  14. // :CODE:
  15. // by Aine Caoimhe January 2015
  16. // Provided under Creative Commons Attribution-Non-Commercial-ShareAlike 4.0 International license.
  17. // Please be sure you read and adhere to the terms of this license: https://creativecommons.org/licenses/by-nc-sa/4.0/
  18. //
  19. // rev 1.1 Added GIF capability - Ferd Frederix
  20. // Images from the Gif2SL program can be used. These have the name Texture;X;Y;FPS. The script detects the X, Y and FPS
  21. // numbers and animates the face of the prim to match
  22. // Example: PMAC002;5;4;10 will animate a 5 X 4 GIF at 10 FPS
  23. integer display=1; // face for the main display
  24. integer page;
  25. integer showPageNum=FALSE;
  26. vector floatyColour=<0.0, 1.0, 0.0>;
  27. integer tCount;
  28. integer init=TRUE;
  29. integer textStep;
  30. string textToSay;
  31. list said;
  32. sayText()
  33. {
  34. if (textToSay=="")
  35. {
  36. llOwnerSay("Text finished. Next: slide "+(string)(page+1));
  37. return;
  38. }
  39. string thisText;
  40. integer stop=llSubStringIndex(textToSay,"*DELAY*");
  41. if (stop>-1)
  42. {
  43. thisText=llGetSubString(textToSay,0,stop-1);
  44. float delay=(float)llGetSubString(textToSay,stop+7,stop+11);
  45. textToSay=""+llGetSubString(textToSay,stop+12,-1);
  46. llSetTimerEvent(delay);
  47. }
  48. else
  49. {
  50. thisText=textToSay;
  51. textToSay="";
  52. llSetTimerEvent(0.25);
  53. }
  54. llSay(0," \n"+thisText);
  55. }
  56. gif(integer face, string t)
  57. {
  58. list gif = llParseString2List(t,[";"],[]);
  59. string aname = llList2String(gif,0);
  60. integer X = (integer) llList2String(gif,1);
  61. integer Y = (integer) llList2String(gif,2);
  62. float FPS = (float) llList2String(gif,3);
  63. float product = X * Y;
  64. // Set the new prim texture
  65. llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_TEXTURE,face,t,<1,1,0>,ZERO_VECTOR,0.0]);
  66. if (X && face == 1) {
  67. llSetTextureAnim( ANIM_ON | LOOP, 1, X, Y, 0.0, product, FPS);
  68. } else if (!X && face == 1) {
  69. llSetTextureAnim( LOOP, 1, 1,1, 0.0, 1 , FPS);
  70. }
  71. }
  72. showPage()
  73. {
  74. integer face;
  75. while (face<4)
  76. {
  77. integer tInd=page-1+face;
  78. if ((tInd>=0) && (tInd<tCount)) {
  79. string Texture = llGetInventoryName(INVENTORY_TEXTURE,tInd);
  80. gif(face,Texture);
  81. }
  82. face++;
  83. }
  84. if (showPageNum) llSetText("Page "+(string)(page+1),floatyColour,1.0);
  85. if (init)
  86. {
  87. init=FALSE;
  88. return;
  89. }
  90. string card="~text"+(string)page;
  91. if (llListFindList(said,[card])==-1)
  92. {
  93. said=[]+said+[card];
  94. textToSay=""+osGetNotecard(card);
  95. sayText();
  96. }
  97. }
  98. default
  99. {
  100. state_entry()
  101. {
  102. page=0;
  103. said=[];
  104. if (!showPageNum) llSetText("",ZERO_VECTOR,0.0);
  105. tCount=llGetInventoryNumber(INVENTORY_TEXTURE);
  106. if (tCount<1) llOwnerSay("No textures to display");
  107. //showPage();
  108. }
  109. timer()
  110. {
  111. llSetTimerEvent(0.0);
  112. sayText();
  113. }
  114. on_rez(integer foo)
  115. {
  116. if (llGetAttached()!=0) return; // ignore if worn
  117. else llResetScript();
  118. }
  119. link_message(integer sender, integer val, string message, key users)
  120. {
  121. //llOwnerSay("Heard: "+message);
  122. list data=llParseString2List(message,["|"],[]);
  123. string command=llList2String(data,0);
  124. if (command=="GLOBAL_SYSTEM_RESET") return;
  125. else if (command=="GLOBAL_SYSTEM_GOING_DORMANT") return;
  126. else if (command=="GLOBAL_START_USING") llResetScript();
  127. else if (command=="GLOBAL_USER_STOOD") return;
  128. else if (command=="GLOBAL_ANIMATION_SYNCH_CALLED") return;
  129. else if (command=="GLOBAL_NEW_USER_ASSUMED_CONTROL") return;
  130. else if (command=="GLOBAL_NOTICE_ENTERING_EDIT_MODE") return;
  131. else if (command=="GLOBAL_EDIT_PERSIST_CHANGES") return;
  132. else if (command=="GLOBAL_STORE_ADDON_NOTICE") return;
  133. else if (command=="GLOBAL_EDIT_STORE_TO_CARD") return;
  134. else if (command=="GLOBAL_NOTICE_LEAVING_EDIT_MODE") return;
  135. else
  136. {
  137. list coms=llParseString2List(llList2String(data,1),["{","}"],[]);
  138. string addon=llList2String(coms,0);
  139. if (addon=="ainepres")
  140. {
  141. page=llList2Integer(coms,1);
  142. showPage();
  143. }
  144. }
  145. }
  146. }