_setText.lslp 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. /*********************************************
  4. * Copyright (c) 2009 Paul Preibisch
  5. * GPL 3.0 for the Sloodle Project
  6. *
  7. * Paul G. Preibisch (Fire Centaur in SL)
  8. * fire@b3dMultiTech.com
  9. * http://twitter.com/fire
  10. *
  11. * setText will accept linked messages for incoming text. It will set the text for 3 seconds, then set to blank.
  12. * Put this in a linked prim, and send messags to it using:
  13. *
  14. * llMessageLinked(LINK_SET, SETTEXT_CHANNEL, "TEXT::Clearing stored coordinate|COLOR::(string)RED|BLINK::(string)TRUE+"|BLINK_TIMER::5", NULL_KEY);
  15. */
  16. integer SETTEXT_CHANNEL= 981000; //channel used for hover text
  17. vector getVector(string vStr){
  18. vStr=llGetSubString(vStr, 1, llStringLength(vStr)-2);
  19. list vStrList= llParseString2List(vStr, [","], ["<",">"]);
  20. vector output= <llList2Float(vStrList,0),llList2Float(vStrList,1),llList2Float(vStrList,2)>;
  21. return output;
  22. }//end getVector
  23. vector RED = <0.77278,0.04391,0.00000>;//RED
  24. vector ORANGE = <0.87130,0.41303,0.00000>;//orange
  25. vector YELLOW = <0.82192,0.86066,0.00000>;//YELLOW
  26. vector GREEN = <0.12616,0.77712,0.00000>;//GREEN
  27. vector BLUE = <0.00000,0.05804,0.98688>;//BLUE
  28. vector PINK = <0.83635,0.00000,0.88019>;//INDIGO
  29. vector PURPLE = <0.39257,0.00000,0.71612>;//PURPLE
  30. vector WHITE = <1.000,1.000,1.000>;//WHITE
  31. vector BLACK = <0.000,0.000,0.000>;//BLACK
  32. /***********************************************************************************************
  33. * s() k() i() and v() are used so that sending messages is more readable by humans.
  34. * Ie: instead of sending a linked message as
  35. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  36. * Context is added with a tag: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  37. * All these functions do is strip off the text before the ":" char and return a string
  38. ***********************************************************************************************/
  39. string s (string ss){
  40. return llList2String(llParseString2List(ss, ["::"], []),1);
  41. }//end function
  42. key k (string kk){
  43. return llList2Key(llParseString2List(kk, ["::"], []),1);
  44. }//end function
  45. integer i (string ii){
  46. return llList2Integer(llParseString2List(ii, ["::"], []),1);
  47. }//end function
  48. vector v (string vv){
  49. integer p = llSubStringIndex(vv, "::");
  50. string vString = llGetSubString(vv, p+1, llStringLength(vv));
  51. return getVector(vString);
  52. }//end function
  53. integer blinkTimer =3;
  54. integer debugCheck(){
  55. if (llList2Integer(llGetPrimitiveParams([PRIM_MATERIAL]),0)==PRIM_MATERIAL_FLESH){
  56. return TRUE;
  57. }
  58. else return FALSE;
  59. }
  60. debug(string str){
  61. if (llList2Integer(llGetPrimitiveParams([PRIM_MATERIAL]),0)==PRIM_MATERIAL_FLESH){
  62. llOwnerSay(str);
  63. }
  64. }
  65. default {
  66. state_entry() {
  67. }
  68. link_message(integer sender_num, integer channel, string str, key id) {
  69. if (channel==SETTEXT_CHANNEL){
  70. debug(str);
  71. //TEXT:Welcome Area - Using SLOODLE|COLOR:<0.83635, 0.00000, 0.88019>|BLINK:0|TIMER:0
  72. list cmdList = llParseString2List(str, ["|"], []);
  73. integer blink = i(llList2String(cmdList,2));
  74. blinkTimer = i(llList2String(cmdList,3));
  75. string text = s(llList2String(cmdList,0));
  76. vector color = PINK;//v(llList2String(cmdList,1));
  77. debug(text);
  78. llSetText(text, color, 1.0);
  79. if (blink==TRUE){
  80. llSetTimerEvent(blinkTimer);
  81. }
  82. }
  83. }
  84. timer() {
  85. llSetTimerEvent(0);
  86. llSetText("", <0,0,0>, 1.0);
  87. }
  88. }
  89. // Please leave the following line intact to show where the script lives in Git:
  90. // SLOODLE LSL Script Git Location: mod/enrolbooth-1.0/objects/default/assets/_setText.lslp