Difference between revisions of "PfText"

From Second Life Wiki
Jump to navigation Jump to search
Line 109: Line 109:
         llSetScale(<0.036, 1.2, 0.36>);
         llSetScale(<0.036, 1.2, 0.36>);
         list params = [PRIM_TYPE, PRIM_TYPE_PRISM, 3, <0.2, 0.8, 0.0>, 0.68, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>];
         list params = [PRIM_TYPE, PRIM_TYPE_PRISM, 3, <0.2, 0.8, 0.0>, 0.68, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>];
          
         llSetPrimitiveParams(params);
    llSetPrimitiveParams(params);
         llSetRot(llEuler2Rot(<PI, 0, PI>));
         llSetScale(<0.036, 1.2, 0.36>);
     }
     }
}
}
</lsl>
</lsl>

Revision as of 07:40, 9 March 2009

I admire the work being put into xyText, but life is short, and so should be Source Code. That's why I made my own version.

Features

pfText might or might not be the most powerful version of Text Systems in SL, but it's by far the shortest (1/10 of a typical xytext), and thereby easiest version. It's also easy to add custom and multi language characters.

You can easily add your own favourite characters, like diactitics and other funny stuff. Just make textures, 10x10 characters. You'll probably need at least 2 textures. Write down the printable chars one by one in the showable var. Put the texture's UUIDs into the chartextures list. That's about it.

Installation

Drop the 2 scripts into the root of a linkset of 5 Face prims, as described in xyText et. al.. Say something in chat.

Improving

pfText uses llSetLinkPrimitiveParams. By making a herd of parallel scripts, you would fill a sheet faster than with one of them. bt;dt

License

I wrote this mostly on my own. A few of the float constants are ripped from the older xyText scripts, but I had to change 1 of them. Therefore the Scripts are Copyright 2007- Torrid Luna <torrid@primforge.com> AND The Scripts and any derivative work are licensed as follow:

Some rights reserved: You may use and remix/improve this work as you like, but: Make a visible mark on the project and script, that your work is based on me, Torrid Luna, or Primforge.com. My sister is a lawyer in RL, and she's leading a Karate school in Berlin, Kreuzberg, Germany, Terra. You have been warned.^^


Scripts

pfText Script

<lsl> // pfText // Copyright 2007- Torrid Luna <torrid@primforge.com> // Some rights reserved: You may use and remix/improve this work as you like, but: // Make a visible mark on the project and script, that your work is based on me, Torrid Luna, and/or Primforge.com. // My sister is a lawyer in RL, and she's leading a Karate school in Berlin, Kreuzberg, Germany, Terra. You have been warned.^^

string showable; list chartextures; list faces = [1,6,4,7,3];

list offsets = [<0.12, 0.1, 0>, <0.037, 0, 0>, <0.05, 0.1, 0>, <0,0,0>, <-0.74, 0.1, 0>, <0.244, 0, 0>, <0.05, 0.1, 0>, <0,0,0>, <0.12, 0.1, 0>, <-0.037, 0, 0>];


default{

   state_entry(){
       showable = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ";
       showable += "[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~·";
       showable += "\n\n\n\n";
       showable +="ÄäÖöÜüßſÅåĄąÆæƏəĆćÇÐðđĘęĦħIJijŁłŃńÑñŊŋÓóÕõ";
       showable +="ŒœØø\n\nȘșŦțȚțÞþŨũŸÿÝý";
       
       chartextures = ["f8638022-4e35-d9de-053b-072b3cdd31ce", "d68b35a5-8f3d-b19c-6455-fd1d2bc9521b"];


   }
   link_message(integer sender, integer num, string str, key id){
       integer i;
       list alletters;
       for(i=0;i<5;i++){
           string thischar = llGetSubString(str, i,i);
           integer charindex = llSubStringIndex(showable, thischar);
           
           integer row = charindex / 10;
           integer col = charindex % 10;
           
           vector offset = <-0.45 + 0.1 * col, 0.45 - 0.1 * row, 0.0>;
           
           key texture = llList2Key(chartextures, charindex / 100);
           integer face = llList2Integer(faces, i);
           
           vector offset1 = llList2Vector(offsets, i*2);
           vector offset2 = llList2Vector(offsets, i*2 +1);
           
           // llSetPrimitiveParams([PRIM_TEXTURE, face, texture, offset1, offset + offset2, PI]);
           alletters += [PRIM_TEXTURE, face, texture, offset1, offset + offset2, PI];
       }
       llSetLinkPrimitiveParams(num+1, alletters);
   }

} </lsl>


pfText chat Example

<lsl> // pfText example // Copyright 2007- Torrid Luna <torrid@primforge.com> // Some rights reserved: You may use and remix/improve this work as you like, but: // Make a visible mark on the project and script, that your work is based on me, Torrid Luna, and/or Primforge.com. // My sister is a lawyer in RL, and she's leading a Karate school in Berlin, Kreuzberg, Germany, Terra. You have been warned.^^

default{

   state_entry(){
       llListen(0, "", llGetOwner(), "");
   }
   listen(integer c, string name, key k, string msg){
       // meant for up to 5 prims. Know what you do. 
       msg = llGetSubString(msg + "                      ", 0, 24);
       // llOwnerSay("stringlength: " + (string)llStringLength(msg));
       integer length = (llStringLength(msg) - 1)/ 5 +1;
       integer i;
       for(i=0;i<length;i++){
           string sub = llGetSubString(msg, i*5, ((i+1)*5 - 1));
           llMessageLinked(LINK_THIS, i, sub, NULL_KEY);
       }
   }

} </lsl>

pfText primFormer

<lsl> default{

   state_entry(){
       llSetScale(<0.036, 1.2, 0.36>);
       list params = [PRIM_TYPE, PRIM_TYPE_PRISM, 3, <0.2, 0.8, 0.0>, 0.68, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>];
       llSetPrimitiveParams(params);
       llSetRot(llEuler2Rot(<PI, 0, PI>));
   }

} </lsl>