Difference between revisions of "Simplex Text"

From Second Life Wiki
Jump to navigation Jump to search
m (Script formatting)
 
(2 intermediate revisions by one other user not shown)
Line 5: Line 5:
The script is also available here on the Wiki, for those intrepid users who wish to dive right in.
The script is also available here on the Wiki, for those intrepid users who wish to dive right in.


{{ LSL SCRIPT }}
    // PRELIMINARY NOTES:
 
    //
// PRELIMINARY NOTES:
    // ALL CHARACTER PRIM BLOCKS MUST BE NAMED "CHARACTER" THIS IS DONE TO ENSURE NO OTHER PRIMS ARE ALTERED.
//
    // ALL OBJECTS MUST BE LINKED. THIS SCRIPT IS IN THE ROOT PRIM.
// ALL CHARACTER PRIM BLOCKS MUST BE NAMED "CHARACTER" THIS IS DONE TO ENSURE NO OTHER PRIMS ARE ALTERED.
   
// ALL OBJECTS MUST BE LINKED. THIS SCRIPT IS IN THE ROOT PRIM.
    // PLEASE MODIFY THESE VARIABLES TO YOUR LIKING
 
   
// PLEASE MODIFY THESE VARIABLES TO YOUR LIKING
    integer face = 3; // FACE NUMBER WHICH THE LETTERS WILL SHOW UP ON (USE ALL_SIDES IF YOU'RE NOT SURE)
 
    vector color = <1, 1, 1>; // COLOR OF TEXT <1, 1, 1> = (RGB) WHITE, <0, 0, 0> = (RGB) BLACK
integer face = 3; // FACE NUMBER WHICH THE LETTERS WILL SHOW UP ON (USE ALL_SIDES IF YOU'RE NOT SURE)
   
vector color = <1, 1, 1>; // COLOR OF TEXT <1, 1, 1> = (RGB) WHITE, <0, 0, 0> = (RGB) BLACK
    // END USER CONTENT
 
   
// END USER CONTENT
    list charOrder = [];
 
    key ascii = "b2e7394f-5e54-aa12-6e1c-ef327b6bed9e";
list charOrder = [];
    string gCharIndex  = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz";
key ascii = "b2e7394f-5e54-aa12-6e1c-ef327b6bed9e";
    float xOrigin = -0.450;
string gCharIndex  = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz";
    float yOrigin = -0.550;
float xOrigin = -0.450;
    setCharacter(integer linknum, string msg)
float yOrigin = -0.550;
setCharacter(integer linknum, string msg)
{
    integer index = llSubStringIndex(gCharIndex, msg);
    float xOffset = xOrigin + (index % 10)/10.f;
    if(xOffset > 1) xOffset -= 1.f;
    if(xOffset < -1) xOffset += 1.f;
    float yOffset = yOrigin - (index / 10)/10.f;
    if(yOffset > 1) yOffset -= 1.f;
    if(yOffset < -1) yOffset += 1.f;
    llSetLinkPrimitiveParamsFast(linknum, [PRIM_TEXTURE, face, ascii, <0.1, 0.1, 0>, <xOffset, yOffset, 0>, 0, PRIM_COLOR, face, color, 1.0]);
}
 
setCharacters(string msg, list order)
{
    integer i;
    for(i = 0; i < llGetListLength(order); i ++)
     {
     {
        setCharacter(llList2Integer(order, i), llGetSubString(msg, i, i));
    integer index = llSubStringIndex(gCharIndex, msg);
    float xOffset = xOrigin + (index % 10)/10.f;
    if(xOffset > 1) xOffset -= 1.f;
    if(xOffset < -1) xOffset += 1.f;
    float yOffset = yOrigin - (index / 10)/10.f;
    if(yOffset > 1) yOffset -= 1.f;
    if(yOffset < -1) yOffset += 1.f;
    llSetLinkPrimitiveParamsFast(linknum, [PRIM_TEXTURE, face, ascii, <0.1, 0.1, 0>, <xOffset, yOffset, 0>, 0, PRIM_COLOR, face, color, 1.0]);
     }
     }
}
   
default
     setCharacters(string msg, list order)
{
     state_entry()
     {
     {
        list temp;
    integer i;
       
    for(i = 0; i < llGetListLength(order); i ++)
        // Set Up Letter Blocks
    {
       
    setCharacter(llList2Integer(order, i), llGetSubString(msg, i, i));
        integer linked = llGetNumberOfPrims();
    }
       
        integer i;
        for(i = 2; i <= linked; i ++)
        {
            if(llGetLinkName(i) == "Character")
            {
                vector pos = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_POSITION]), 0);
                vector posNorm = llVecNorm(pos)*llGetRot();
                temp += pos*llRot2Up(llGetRot())+posNorm.x;
                temp += i;
            }
        }
        charOrder = llList2ListStrided(llDeleteSubList(llListSort(temp, 2, FALSE), 0, 0), 0, -1, 2);
     }
     }
     link_message(integer linknum, integer num, string str, key id)
     default
     {
     {
        llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_COLOR, ALL_SIDES, <0, 0, 0>, 0.0]);
    state_entry()
        setCharacters(str, charOrder);
    {
    list temp;
   
    // Set Up Letter Blocks
   
    integer linked = llGetNumberOfPrims();
   
    integer i;
    for(i = 2; i <= linked; i ++)
    {
    if(llGetLinkName(i) == "Character")
    {
    vector pos = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_POSITION]), 0);
    vector posNorm = llVecNorm(pos)*llGetRot();
    temp += pos*llRot2Up(llGetRot())+posNorm.x;
    temp += i;
    }
    }
    charOrder = llList2ListStrided(llDeleteSubList(llListSort(temp, 2, FALSE), 0, 0), 0, -1, 2);
    }
    link_message(integer linknum, integer num, string str, key id)
    {
    llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_COLOR, ALL_SIDES, <0, 0, 0>, 0.0]);
    setCharacters(str, charOrder);
    }
    changed(integer change)
    {
    if(change & CHANGED_LINK)
    {
    llResetScript();
    }
    }
     }
     }
    changed(integer change)
    {
        if(change & CHANGED_LINK)
        {
            llResetScript();
        }
    }
}

Latest revision as of 02:34, 1 August 2023

Simplex Text is, in the creator's opinion, the successor to XyzzyText. Whether that is true or not, the future will decide. Simplex provides end users an easy way to generate dynamic text on prims. Using only one texture and one script, this becomes a viable option for many users. Unfortunately, unlike XyzzyText, it uses a linkset, rather than a single prim, to visualize its contents.

Rudy Glassfield, the sole developer of Simplex Text, has made the script open-source and currently sells it on the Marketplace for free. The script comes packaged in a box, which doubles up as a demo for the Simplex Text System.

The script is also available here on the Wiki, for those intrepid users who wish to dive right in.

   // PRELIMINARY NOTES:
   //
   // ALL CHARACTER PRIM BLOCKS MUST BE NAMED "CHARACTER" THIS IS DONE TO ENSURE NO OTHER PRIMS ARE ALTERED.
   // ALL OBJECTS MUST BE LINKED. THIS SCRIPT IS IN THE ROOT PRIM.
   
   // PLEASE MODIFY THESE VARIABLES TO YOUR LIKING
   
   integer face = 3; // FACE NUMBER WHICH THE LETTERS WILL SHOW UP ON (USE ALL_SIDES IF YOU'RE NOT SURE)
   vector color = <1, 1, 1>; // COLOR OF TEXT <1, 1, 1> = (RGB) WHITE, <0, 0, 0> = (RGB) BLACK
   
   // END USER CONTENT
   
   list charOrder = [];
   key ascii = "b2e7394f-5e54-aa12-6e1c-ef327b6bed9e";
   string gCharIndex  = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz";
   float xOrigin = -0.450;
   float yOrigin = -0.550;
   setCharacter(integer linknum, string msg)
   {
   	integer index = llSubStringIndex(gCharIndex, msg);
   	float xOffset = xOrigin + (index % 10)/10.f;
   	if(xOffset > 1) xOffset -= 1.f;
   	if(xOffset < -1) xOffset += 1.f;
   	float yOffset = yOrigin - (index / 10)/10.f;
   	if(yOffset > 1) yOffset -= 1.f;
   	if(yOffset < -1) yOffset += 1.f;
   	llSetLinkPrimitiveParamsFast(linknum, [PRIM_TEXTURE, face, ascii, <0.1, 0.1, 0>, <xOffset, yOffset, 0>, 0, PRIM_COLOR, face, color, 1.0]);
   }
   
   setCharacters(string msg, list order)
   {
   	integer i;
   	for(i = 0; i < llGetListLength(order); i ++)
   	{
   		setCharacter(llList2Integer(order, i), llGetSubString(msg, i, i));
   	}
   }
   default
   {
   	state_entry()
   	{
   		list temp;
   		
   		// Set Up Letter Blocks
   		
   		integer linked = llGetNumberOfPrims();
   		
   		integer i;
   		for(i = 2; i <= linked; i ++)
   		{
   			if(llGetLinkName(i) == "Character")
   			{
   				vector pos = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_POSITION]), 0);
   				vector posNorm = llVecNorm(pos)*llGetRot();
   				temp += pos*llRot2Up(llGetRot())+posNorm.x;
   				temp += i;
   			}
   		}
   		charOrder = llList2ListStrided(llDeleteSubList(llListSort(temp, 2, FALSE), 0, 0), 0, -1, 2);
   	}
   	link_message(integer linknum, integer num, string str, key id)
   	{
   		llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_COLOR, ALL_SIDES, <0, 0, 0>, 0.0]);
   		setCharacters(str, charOrder);
   	}
   	changed(integer change)
   	{
   		if(change & CHANGED_LINK)
   		{
   			llResetScript();
   		}
   	}
   }