PfText

From Second Life Wiki
Jump to: navigation, search

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. (Update, I added a 3rd script to make you a 5 Face prim. You only need that once, delete it after use.)

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

All content submitted to Second Life Wiki is contributed to Linden Lab under the Second Life Wiki Contribution Agreement (see Project:Contribution Agreement for details). Linden Lab will make your contribution available under the Creative Commons Creative Commons Attribution-Share Alike 3.0 license (see Project:Copyrights for details). If you don't want your writing to be edited mercilessly and redistributed at will, then don't submit it here.

Contact

If you need help with this or other scripts, contact Torrid Luna or any other member of the Virtyou group in-world, or check out our website virtyou.com. We are a full service Solution Provider working and scripting for RL customers since Feb. 2007.

Scripts

pfText Script

<lsl> // pfText // Copyright 2007- 2009 Torrid Luna <torrid@primforge.com> http://primforge.com/ // https://wiki.secondlife.com/wiki/Project:Copyrights#Contributing_to_the_Wiki

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- 2009 Torrid Luna <torrid@primforge.com> http://primforge.com/ // https://wiki.secondlife.com/wiki/Project:Copyrights#Contributing_to_the_Wiki

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>