Advertisement
salahzar

sxymesh-1000-10999

Mar 18th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ////////////////////////////////////////////
  2. // SALTEXT Novembre 2012
  3. //
  4. // Inspired by Xylor Baysklef, Kermitt Quirk
  5. //
  6. //
  7. ////////////////////////////////////////////
  8.  
  9. debug(string x) {} // llOwnerSay("debug: "+x); }
  10. _debug(string x) { llMessageLinked(LINK_SET,-2,llGetTimestamp()+" "+llGetScriptName()+":"+x,NULL_KEY); }
  11. //#define debug(x) // llOwnerSay(x)
  12.  
  13. integer NCELLS=6;
  14. /////////////// CONSTANTS ///////////////////
  15.  
  16.  
  17. // number of characters for each "line" in texture
  18. integer knum=10;            
  19. integer start=0;                      
  20.      
  21.  
  22. // adjusting offset + multipliers for columns and rows
  23. vector kcol=<-0.44,0.10,0>; // offset + multiplier for cols
  24. vector krow=<0.422,-0.05,0>; // offset + multiplier for rows
  25. vector kmul=<0.07,0.05,0>;
  26.  
  27.  
  28. list decode =
  29.            [ "%C3%87", "%C3%BC", "%C3%A9", "%C3%A2", "%C3%A4", "%C3%A0", "%C3%A5", "%C3%A7", "%C3%AA", "%C3%AB",
  30.              //           è         ï          î         ì         Ä         Å         É         æ         Æ    BLACK RIGHT-POINTING TRIANGLE
  31.                        "%C3%A8", "%C3%AF", "%C3%AE", "%C3%AC", "%C3%84", "%C3%85", "%C3%89", "%C3%A6", "%C3%AE", "%E2%96%B6",
  32.              //           ö         ò          û         ù         ÿ         Ö         Ü         ¢         £         ¥
  33.                        "%C3%B6", "%C3%B2", "%C3%BB", "%C3%B9", "%C3%BF", "%C3%96", "%C3%9C", "%C2%A2", "%C2%A3", "%C2%A5",
  34.              //           A^    copyright     á         í         ó         ú         ñ         Ñ         ª          º"
  35.                        "%C3%82", "%C2%A9", "%C3%A1", "%C3%AD", "%C3%B3", "%C3%BA", "%C3%B1", "%C3%91", "%C2%AA", "%C2%BA",
  36.              //            ¿        O^         ¬        ½         ¼          ¡         «        »       alfa          ß"
  37.                        "%C2%BF", "%C3%94", "%C2%AC", "%C2%BD", "%C2%BC", "%C2%A1", "%C2%AB", "%C2%BB", "%CE%B1", "%C3%9F",
  38.              //           gamma      pi      bigsigma  smsigma    mu  
  39.                        "%CE%93", "%CF%80", "%CE%A3", "%CF%83", "%C2%B5",
  40.                      
  41.              //                              tau       BIGfi      theta       omega   delta  
  42.              "%CF%84", "%CE%A6", "%CE%98", "%CE%A9", "%CE%B4",
  43.              //         Uu          uu       EPS         INTERS        3bars        +-         <=           >=        INTEGRUP   INTEGRDOWN
  44.                        "%C5%AC", "%C5%AD", "%CE%B5", "%E2%88%A9", "%E2%89%A1", "%C2%B1", "%E2%89%A5", "%E2%89%A4", "%E2%8C%A0", "%E2%8C%A1",
  45.              //           A/       A\        a~         A~       E^         I/        O/        o~       O~        o^
  46.                        "%C3%81", "%C3%80", "%C3%A3", "%C3%83", "%C3%8A", "%C3%8D", "%C3%93", "%C3%B5", "%C3%95", "%C3%B4" ];
  47.  
  48.  
  49. ///////////// END CONSTANTS ////////////////
  50.  
  51. ///////////// GLOBAL VARIABLES ///////////////
  52. // This is the key of the font we are displaying.
  53. key     gFontTexture        = "font";
  54. // All displayable characters.  Default to ASCII order.
  55. string gCharIndex;
  56. // This is the channel to listen on while acting
  57. // as a cell in a larger display.
  58. integer gCellChannel        = -1;
  59. // This is the starting character position in the cell channel message
  60. // to render.
  61. integer gCellCharPosition   = 0;
  62. // This is whether or not to use the fade in/out special effect.
  63. integer gCellUseFading      = FALSE;
  64. // This is how long to display the text before fading out (if using
  65. // fading special effect).
  66. // Note: < 0  means don't fade out.
  67. float   gCellHoldDelay      = 1.0;
  68. /////////// END GLOBAL VARIABLES ////////////
  69.  
  70. ResetCharIndex() {
  71.  
  72.      gCharIndex  = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`";
  73.      gCharIndex += "abcdefghijklmnopqrstuvwxyz{|}~\n\n\n\n\n";
  74.  
  75.      //decode=[];
  76.      
  77. }
  78.  
  79. vector GetGridOffset(integer index) {
  80.    // Calculate the offset needed to display this character.
  81.    integer Row = index / knum - 1;
  82.    integer Col = index % knum;
  83.  
  84.    // Return the offset in the texture.
  85.    return < kcol.x + kcol.y * Col, krow.x + krow.y * Row, 0.0>;
  86. }
  87. ShowChars(integer linknum, vector grid_offset1, vector grid_offset2, vector grid_offset3, vector grid_offset4, vector grid_offset5, vector grid_offset6, vector grid_offset7, vector grid_offset8) {
  88.    // Set the primitive textures directly.
  89.    
  90.    llSetLinkPrimitiveParamsFast( linknum, [
  91.         PRIM_TEXTURE, 0, (string)gFontTexture, kmul, grid_offset1, 0.0,
  92.         PRIM_TEXTURE, 1, (string)gFontTexture, kmul, grid_offset2, 0.0,
  93.         PRIM_TEXTURE, 2, (string)gFontTexture, kmul, grid_offset3, 0.0,
  94.         PRIM_TEXTURE, 3, (string)gFontTexture, kmul, grid_offset4, 0.0,
  95.         PRIM_TEXTURE, 4, (string)gFontTexture, kmul, grid_offset5, 0.0,
  96.         PRIM_TEXTURE, 5, (string)gFontTexture, kmul, grid_offset6, 0.0,
  97.         PRIM_TEXTURE, 6, (string)gFontTexture, kmul, grid_offset7, 0.0,
  98.         PRIM_TEXTURE, 7, (string)gFontTexture, kmul, grid_offset8, 0.0
  99.         ]);
  100. }
  101.  
  102. // SALAHZAR intelligent procedure to extract UTF-8 codes and convert to index in our "cp850"-like table
  103. integer GetIndex(string char)
  104. {
  105.     integer  ret=llSubStringIndex(gCharIndex, char);
  106.    // llSay(0,"pos: "+(string)ret);
  107.     if(ret>=0) return ret;
  108.  
  109.     // special char do nice trick :)
  110.     string escaped=llEscapeURL(char);
  111.    // llSay(0,"char: "+escaped+" "+llList2CSV(decode));
  112.     integer found=llListFindList(decode, [escaped]);
  113.  
  114.     // Return blank if not found
  115.     if(found<0) return 0;
  116.  
  117.     // return correct index
  118.   //  llSay(0,"returning "+(string)(100+found));
  119.     return 100+found;
  120.  
  121. }
  122. // END SALAHZAR
  123.  
  124.  
  125. RenderString(integer linknum, string str) {
  126.     debug("telling link "+(string)linknum+" str {"+str+"}");
  127.    // Get the grid positions for each pair of characters.
  128.    vector GridOffset1 = GetGridOffset( GetIndex(llGetSubString(str, 0, 0)) ); // SALAHZAR intermediate function
  129.    vector GridOffset2 = GetGridOffset( GetIndex(llGetSubString(str, 1, 1)) ); // SALAHZAR
  130.    vector GridOffset3 = GetGridOffset( GetIndex(llGetSubString(str, 2, 2)) ); // SALAHZAR
  131.    vector GridOffset4 = GetGridOffset( GetIndex(llGetSubString(str, 3, 3)) ); // SALAHZAR
  132.    vector GridOffset5 = GetGridOffset( GetIndex(llGetSubString(str, 4, 4)) ); // SALAHZAR
  133.    vector GridOffset6 = GetGridOffset( GetIndex(llGetSubString(str, 5, 5)) ); // SALAHZAR
  134.    vector GridOffset7 = GetGridOffset( GetIndex(llGetSubString(str, 6, 6)) ); // SALAHZAR
  135.    vector GridOffset8 = GetGridOffset( GetIndex(llGetSubString(str, 7, 7)) ); // SALAHZAR
  136.      
  137.  
  138.    // Use these grid positions to display the correct textures/offsets.
  139.     llSetLinkPrimitiveParamsFast( linknum, [
  140.         PRIM_TEXTURE, 0, (string)gFontTexture, kmul, GridOffset1, 0.0,
  141.         PRIM_TEXTURE, 1, (string)gFontTexture, kmul, GridOffset2, 0.0,
  142.         PRIM_TEXTURE, 2, (string)gFontTexture, kmul, GridOffset3, 0.0,
  143.         PRIM_TEXTURE, 3, (string)gFontTexture, kmul, GridOffset4, 0.0,
  144.         PRIM_TEXTURE, 4, (string)gFontTexture, kmul, GridOffset5, 0.0,
  145.         PRIM_TEXTURE, 5, (string)gFontTexture, kmul, GridOffset6, 0.0,
  146.         PRIM_TEXTURE, 6, (string)gFontTexture, kmul, GridOffset7, 0.0,
  147.         PRIM_TEXTURE, 7, (string)gFontTexture, kmul, GridOffset8, 0.0
  148.         ]);
  149.   // ShowChars(linknum, GridOffset1, GridOffset2, GridOffset3, GridOffset4, GridOffset5, GridOffset6, GridOffset7, GridOffset8);
  150. }
  151.  
  152.  
  153.  
  154.  
  155. parseMessage(string m, integer row)
  156. {
  157.     debug("Parsing message {"+m+"} to row: "+(string)row);
  158.      
  159.       integer i; integer j;
  160.      
  161.      
  162.            for(j=0;j<g_length;j++)
  163.            {
  164.                string element=llGetSubString(m,j*8,(j+1)*8-1);
  165.                integer found=llListFindList(g_lookup,[ (string)(row+j) ]);
  166.                 if(found>=0){
  167.                  integer linknumber=llList2Integer(g_lookup,found+1);
  168.            
  169.                RenderString(linknumber,element);
  170.             }
  171.            }
  172.       // for(i=start;i<llGetNumberOfPrims();i++) RenderString(i+1,"    ");
  173. }
  174.  
  175. string g_name;
  176. integer g_start;
  177. integer g_end;
  178. integer  g_length;
  179.  
  180. list g_lookup; // pairs name + linknumber
  181.  
  182.  
  183. default {
  184.    state_entry() {
  185.        debug("Initialize "+llGetScriptName());
  186.        // Initialize the character index.
  187.        list bits=llParseStringKeepNulls(llGetScriptName(),["-"],[]);
  188.         g_name=llList2String(bits,0);
  189.         g_start=(integer)llList2String(bits,1);
  190.         g_end=(integer)llList2String(bits,2);
  191.        
  192.         g_length=(integer)llList2String(bits,3);
  193.        debug("Start: "+(string)g_start+", End: "+(string)g_end+", length: "+(string)g_length);
  194.        ResetCharIndex();
  195.        integer i; g_lookup=[];
  196.        for(i=1;i<=llGetNumberOfPrims();i++)
  197.        {
  198.            string pname=llGetLinkName(i);
  199.            integer iname=(integer)pname;
  200.            if(iname>=g_start && iname<=g_end)
  201.            {
  202.                debug("adding {"+pname+"} link: "+(string)i);
  203.                g_lookup+=[ pname, i ];
  204.            }
  205.        }
  206.        debug("parsing");
  207.        integer r; for(r=1000;r<30000;r+=1000)
  208.        parseMessage(llGetScriptName()+ " {ABCDEFGHIJKLMNOPQRSTUVWXYZàèìòù}",r);
  209.     }
  210.     link_message(integer sender,integer channel,string str,key id)
  211.     {
  212.         if(channel>= g_start && channel <=g_end ) parseMessage(str,channel);
  213.     }
  214.  
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement