sloodle_hover_text_displayer.lslp 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. /*
  4. *********************************************************************************************
  5. * sloodle_hover_text_displayer.lsl
  6. * Copyright (c) 2009 Paul Preibisch
  7. * Released under the GNU GPL 3.0
  8. * This script can be used in your scripts, but you must include this copyright header as per the GPL Licence
  9. * For more information about GPL 3.0 - see: http://www.gnu.org/copyleft/gpl.html
  10. *
  11. *
  12. * This script is part of the SLOODLE Project see http://sloodle.org
  13. * This script can be dropped into a linked prim, and messages can be sent to it on channel SETTEXT_CHANNEL=-776644 to set the text above
  14. * This way you can better position where setText get's printed
  15. * You should name the linked prim a unique name, then send this command to it via a linked message
  16. * example: DISPLAY:top display|STRING:some string|COLOR:"+<0,0.5,0>
  17. * example: llMessageLinked(LINK_SET,SETTEXT_CHANNEL,"DISPLAY:top display|STRING:"+text+"|COLOR:"+(string)GREEN,NULL_KEY);
  18. *
  19. * Copywrite 2009
  20. * Paul G. Preibisch (Fire Centaur in SL)
  21. * fire@b3dMultiTech.com
  22. **********************************************************************************************
  23. */
  24. integer SETTEXT_CHANNEL=-776644;
  25. list commandList; //used for linked_message strings
  26. /***********************************************
  27. * extractResponse()
  28. * Is used so that sending of linked messages is more readable by humans. Ie: instead of sending a linked message as
  29. * GETDATA|50091bcd-d86d-3749-c8a2-055842b33484
  30. * Context is added instead: COMMAND:GETDATA|PLAYERUUID:50091bcd-d86d-3749-c8a2-055842b33484
  31. * By adding a context to the messages, the programmer can understand whats going on when debugging
  32. * All this function does is strip off the text before the ":" char
  33. ***********************************************/
  34. string extractResponse(string cmd){
  35. return llList2String(llParseString2List(cmd, ["::"],[]),1);
  36. }
  37. default {
  38. /***********************************************
  39. * on_rez event
  40. * |--> Reset Script to ensure proper defaults on rez
  41. ***********************************************/
  42. on_rez(integer start_param) {
  43. llResetScript();
  44. }
  45. /***********************************************
  46. * state_entry
  47. * |-->
  48. ***********************************************/
  49. state_entry() {
  50. llSetText("",<0,0,0>,1.0);
  51. }
  52. /***********************************************
  53. * changed event
  54. * |-->Every time the inventory changes, reset the script
  55. *
  56. ***********************************************/
  57. changed(integer change) {
  58. if (change ==CHANGED_INVENTORY){
  59. llSetText(" ",<0,0,0>,1.0);
  60. llResetScript();
  61. }
  62. }
  63. link_message(integer sender_num, integer channel, string str, key id) {
  64. if (channel==SETTEXT_CHANNEL){
  65. //llMessageLinked(LINK_SET,SETTEXT_CHANNEL,"DISPLAY:top display|STRING:"+text+"|COLOR:"+(string)GREEN,NULL_KEY);
  66. commandList=llParseString2List(str, ["|"],[]);
  67. if (extractResponse(llList2String(commandList,0))==llGetLinkName(llGetLinkNumber())){
  68. string text = extractResponse(llList2String(commandList,1));
  69. vector color = (vector)extractResponse(llList2String(commandList,2));
  70. float alpha = (float)extractResponse(llList2String(commandList,3));
  71. llSetText(text, color, alpha);
  72. }
  73. }
  74. }
  75. }
  76. // Please leave the following line intact to show where the script lives in Git:
  77. // SLOODLE LSL Script Git Location: assets/sloodle_hover_text_displayer.lslp