twitterwall.lslp 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. integer SLOODLE_CHANNEL_SET_SET_SHARED_MEDIA_URL_OWNER = -1639270111; // set the main shared media panel to the specified URL, accessible to the owner
  4. integer SLOODLE_CHANNEL_SET_SET_SHARED_MEDIA_URL_GROUP = -1639270112; // set the main shared media panel to the specified URL, accessible to the group
  5. integer SLOODLE_CHANNEL_SET_SET_SHARED_MEDIA_URL_ANYONE = -1639270114; // set the main shared media panel to the specified URL, accessible to anyone
  6. integer side = 0;
  7. string searchterm="";
  8. string caption = "";
  9. string title = "";
  10. setData(string searchTerm,string caption,string title){
  11. llClearPrimMedia(side);
  12. string twitterText ="<body><script>";
  13. twitterText +="new TWTR.Widget({";
  14. twitterText +="version: 2,";
  15. twitterText +="type: 'search',";
  16. twitterText +="search: '"+searchTerm+"',";
  17. twitterText +="interval: 30000,";
  18. twitterText +="title: '"+title+"',";
  19. twitterText +="subject: '"+caption+"',";
  20. twitterText +="width: 250,";
  21. twitterText +="height: 300,";
  22. twitterText +="theme: {";
  23. twitterText +="shell: {";
  24. twitterText +="background: '#7c001a',";
  25. twitterText +="color: '#ffffff'";
  26. twitterText +="},";
  27. twitterText +="tweets: {";
  28. twitterText +="background: '#ffffff',";
  29. twitterText +="color: '#444444',";
  30. twitterText +="links: '#1985b5'";
  31. twitterText +="}";
  32. twitterText +="},";
  33. twitterText +="features: {";
  34. twitterText +="scrollbar: false,";
  35. twitterText +="loop: true,";
  36. twitterText +="live: true,";
  37. twitterText +="hashtags: true,";
  38. twitterText +="timestamp: true,";
  39. twitterText +="avatars: true,";
  40. twitterText +="toptweets: true,";
  41. twitterText +="behavior: 'default'";
  42. twitterText +="}";
  43. twitterText +="}).render().start();";
  44. twitterText +="</script>";
  45. string url = "data:text/html,<head><script src=\"http://widgets.twimg.com/j/2/widget.js\"></script></head>";
  46. url+=twitterText+ "</body>";
  47. llSetPrimMediaParams( side, [ PRIM_MEDIA_CURRENT_URL, url, PRIM_MEDIA_HOME_URL, url, PRIM_MEDIA_FIRST_CLICK_INTERACT, TRUE, PRIM_MEDIA_AUTO_ZOOM, TRUE, PRIM_MEDIA_AUTO_PLAY, TRUE, PRIM_MEDIA_PERMS_INTERACT, PRIM_MEDIA_PERM_OWNER, PRIM_MEDIA_PERMS_CONTROL, PRIM_MEDIA_PERM_NONE ] );
  48. }
  49. string text;
  50. integer channel;
  51. string SLOODLE_EOF = "sloodleeof";
  52. integer eof= FALSE;
  53. integer isconfigured=FALSE;
  54. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343; // an arbitrary channel the sloodle scripts will use to talk to each other. Doesn't atter what it is, as long as the same thing is set in the sloodle_slave script.
  55. string chalkboardtext;
  56. integer newChannel;
  57. integer sloodle_handle_command(string str)
  58. {
  59. list bits = llParseString2List(str,["|"],[]);
  60. integer numbits = llGetListLength(bits);
  61. string name = llList2String(bits,0);
  62. string value1 = "";
  63. string value2 = "";
  64. if (numbits > 1) value1 = llList2String(bits,1);
  65. if (numbits > 2) value2 = llList2String(bits,2);
  66. if (name == "set:searchterm"){
  67. searchterm= (string)value1;
  68. }else
  69. if (name == "set:caption"){
  70. caption= (string)value1;
  71. }else
  72. if (name == "set:title"){
  73. title= (string)value1;
  74. }else
  75. if (name == "set:channel"){
  76. channel= (integer)value1;
  77. llListenRemove(newChannel);
  78. newChannel = llListen(channel, "", llGetOwner(), "");
  79. llOwnerSay("Listening to " +llKey2Name(llGetOwner())+" on "+(string)channel+" \nType /"+(string)channel+" searchterm, to change the search term");
  80. }
  81. else if (name == SLOODLE_EOF) eof = TRUE;
  82. return (searchterm != ""&&caption!=""&&title!="");
  83. }
  84. default
  85. {
  86. // touch_start(integer d){
  87. //}
  88. state_entry(){
  89. //llClearPrimMedia( side);
  90. llListenRemove(newChannel);
  91. newChannel = llListen(channel, "", llGetOwner(), "");
  92. llOwnerSay("Listening to " +llKey2Name(llGetOwner())+" on "+(string)channel+" \nType /"+(string)channel+" searchterm, to change the search term");
  93. }
  94. listen(integer channel, string name, key id, string message) {
  95. llClearPrimMedia(side);
  96. setData(message,caption,title);
  97. }
  98. link_message( integer sender_num, integer num, string str, key id)
  99. {
  100. // Check the channel
  101. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  102. // Split the message into lines
  103. list lines = llParseString2List(str, ["\n"], []);
  104. integer numlines = llGetListLength(lines);
  105. integer i = 0;
  106. for (i=0; i < numlines; i++) {
  107. isconfigured = sloodle_handle_command(llList2String(lines, i));
  108. }if (isconfigured){
  109. setData(searchterm,caption,title);
  110. }
  111. }
  112. }
  113. on_rez(integer start_param) {
  114. llClearPrimMedia(side);
  115. // Give the object a starting texture.
  116. // If we just use llClearPrimMedia here, we get a strange problem where if you click on it before it's ready, autozoom fails until you look away then look back.
  117. }
  118. }
  119. // Please leave the following line intact to show where the script lives in Git:
  120. // SLOODLE LSL Script Git Location: mod/furniture-1.0/objects/twitterwall/assets/twitterwall.lslp