Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: XY Text Light

Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-04-2007 00:12
Hello, for those who dont know me i LOVE to play with XY systems (numbers text sprites ect)... this comes from the fact that i cannot make heads or tails out of the current XY text scripts on the wiki, but yet it is such a simple concept

I started this project about 1 week before the Scripting Trade Show, but due to sim delays and my time i was never able to attend, i had planned on talking about how to homebrew XY offset scripts, and since i had this quickie already written i thought i would unleash it to the world

this version uses the 5 faced prim, and only displays 1 charater per face, in the near future i will be releasing a single texture 2 charater per face version, but that is another thread

this version is MUCH smaller than normal XY text, and IMO just abit faster

i release this system as openware for anyone to use and and learn from, if you use the scripts in their original form please include a footnote to me in your projects credits :)

lets get started

5 FACE PRIM SETUP

this is the 5 face prim setup script from the wiki, edited for this system. Two things you need to do manually

1 the center face needs to be flipped on its Horizontal axis
2 if you want fullbright i didnt add it into the setup script

CODE

////////////////////////////////////////////
// XyText Prim Setup
// Written by Gearsawe Stonecutter
// Modded For XY Text Light by Osgeld Barmy
////////////////////////////////////////////

string FACE_TEXTURE = "44891a22-1aba-c86f-2314-67a04ca24f48";
string TRANSPARENT = "701917a8-d614-471f-13dd-5f4644e36e3c";

default
{
state_entry()
{
llSetPrimitiveParams([

PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_DEFAULT, <0.199, 0.8, 0.0>, 0.68,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,

// display a default face texture
PRIM_TEXTURE, 3, FACE_TEXTURE, <0.280, 0.090, 0.0>, <-0.357, 0.453, 0.0>, 0.0,
PRIM_TEXTURE, 7, FACE_TEXTURE, <0.110, 0.090, 0.0>, <-0.444, 0.453, 0.0>, 0.0,
PRIM_TEXTURE, 4, FACE_TEXTURE, <1.600, 0.090, 0.0>, <-0.970, 0.453, 0.0>, 0.0,
PRIM_TEXTURE, 6, FACE_TEXTURE, <0.110, 0.090, 0.0>, <-0.445, 0.453, 0.0>, 0.0,
PRIM_TEXTURE, 1, FACE_TEXTURE, <0.280, 0.090, 0.0>, <-0.524, 0.453, 0.0>, 0.0,

// show transparent textures for the other sides
PRIM_TEXTURE, 0, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 2, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 5, TRANSPARENT, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,

PRIM_SIZE, <0.03, 2.89, 0.5>
]);

// Remove ourselves from inventory.
llRemoveInventory(llGetScriptName());
}
}


NOTECARD
i used a notecard to avoid scripting issues with charaters such as " and \
this notecard needs to be named text rom please note the space at the end of the line, this needs to be in place for the script to see " " (spaces) in text, also this needs to be saved on line 0 of the notecard

CODE

ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz)!@#$%^&*(`-=[]\;',./?><":|}{+_~


CONTROL SCRIPT
this is the heart of this system, and needs to be placed in the parent prim of the object
display prims are accessed via link numbers from lowest to highest (get your link orders correct heh)
CODE

//<---------------------------------------------------------------------------------------------->//
//<---------- XY Text Light Control Script ----------------------------------------------------->//
//<------------- 2007 CFDT / Osgeld Barmy ------------------------------------------------------->//
//<---------------------------------------------------------------------------------------------->//

integer line_length = 15; // Length of 1 display line
integer cell_count = 60; // Total amount of faces in display
integer display = 2; // LinkNumber of first display prim
string glyph_index;

default
{
state_entry() {glyph_index = llGetNotecardLine("text rom",0);}

dataserver(key id, string data)
{
if (id == glyph_index)
{
glyph_index = data;
//llOwnerSay((string)llGetFreeMemory()); //DEBUG
state online;
}
}
}

state online
{
link_message(integer sender_num, integer num, string message, key id)
{
integer x;
integer space;
integer cell = display;
integer total = llStringLength(message);

do
{
if (x < cell_count && x > (total - 1)) llMessageLinked(cell,space,"4|10",NULL_KEY);
else
{
float pos = (float) llSubStringIndex(glyph_index,llGetSubString(message,x,x)) / 9;
integer dec = llSubStringIndex((string)pos,".");
//
string data = (
llGetSubString((string)pos,(dec + 1),(dec + 1))
+ "|" +
llGetSubString((string)pos,0,(dec - 1))
);
//
llMessageLinked(cell,space,data,NULL_KEY);
}

if (space == 4) {space = 0; ++cell;}
else {++space;}

++x;
}

while (x < cell_count);
}
}


DISPLAY SCRIPT
this script needs to be placed in each display prim
CODE

//<---------------------------------------------------------------------------------------------->//
//<---------- XY Text Light Display Script ----------------------------------------------------->//
//<------------- 2007 CFDT / Osgeld Barmy ------------------------------------------------------->//
//<---------------------------------------------------------------------------------------------->//

float ho = 0.111;
float vo = 0.090;
float vc = 0.453;

default
{
link_message(integer na, integer space, string data, key id)
{
integer h;
integer v;

integer break = llSubStringIndex(data,"|");
h = (integer)llGetSubString(data,0,(break - 1));
v = (integer)llGetSubString(data,(break + 1), -1);

if (space == 0) llOffsetTexture(-0.357 + (h*ho), vc - (v*vo), 3);
else if (space == 1) llOffsetTexture(-0.444 + (h*ho), vc - (v*vo), 7);
else if (space == 2) llOffsetTexture(-0.970 + (h*ho), vc - (v*vo), 4);
else if (space == 3) llOffsetTexture(-0.445 + (h*ho), vc - (v*vo), 6);
else if (space == 4) llOffsetTexture(-0.524 + (h*ho), vc - (v*vo), 1);
}
}


TEXTURE UUID's
both are 24 bit 256x256 textures

44891a22-1aba-c86f-2314-67a04ca24f48 = Black BG White Font
9494a435-00d3-cf03-aea7-b882e44fba58 = White BG Black Font

Here is everything above in txt format, since the forums loves to bugger up lsl formating
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
01-06-2007 09:27
/15/8a/158479/1.html
_____________________
i've got nothing. ;)
Wilbert Hilbert
Registered User
Join date: 19 Jun 2006
Posts: 6
newbie question
01-22-2007 02:55
if I wanted to make new textures with different fonts etc. for this or any of the other xy text scripts what would it look like?

(I just started thinking about any text display so will probably find an answer as I delve into the forums but it may be a good reminder to have it posted again if that is the case)

I am assuming it would be one character per square in a grid right... in the same order as the notecard layout?

(hope so because I will probably start on that before reading further... you know read the manual when you get in trouble LOL)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-22-2007 03:29
From: Wilbert Hilbert
if I wanted to make new textures with different fonts etc. for this or any of the other xy text scripts what would it look like?

(I just started thinking about any text display so will probably find an answer as I delve into the forums but it may be a good reminder to have it posted again if that is the case)

I am assuming it would be one character per square in a grid right... in the same order as the notecard layout?

(hope so because I will probably start on that before reading further... you know read the manual when you get in trouble LOL)


This thread should help you out.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
01-22-2007 21:18
yes for single texture single charater XY text its one per block in a grid
for mine its 9 wide X 11 tall
Wilbert Hilbert
Registered User
Join date: 19 Jun 2006
Posts: 6
01-23-2007 09:05
From: Osgeld Barmy
yes for single texture single charater XY text its one per block in a grid
for mine its 9 wide X 11 tall


Thank you :)

That solves the problem and makes it clear what I am doing (was considering writing my own theory to code based on some texture shifting I have done for some other projects... I may still do that for excercise)

I will post UUID's when I have some textures finished.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
03-25-2008 12:15
ok so i've got this all set up, but i can't seem to figure out how to get it to display what i want. do i need a notecard with my phrase? is it in the script? or do i chat it to it on a channel?
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
03-25-2008 14:21
It appears you send a link message to the prim that has the control script in it (only!). The string parameter of the link message is the text you want displayed. The other link message parameters are ignored.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
03-27-2008 17:54
From: Hewee Zetkin
It appears you send a link message to the prim that has the control script in it (only!). The string parameter of the link message is the text you want displayed. The other link message parameters are ignored.

i'm not a very experienced scripter, so this one's alot to take in, can you show me where my message would go? i've tried both systems, and i can't seem to understand it.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
04-19-2008 04:09
I'm trying to make some more textures for this - but with a different layout (more characters)... Trying to get my head around the math to compute the texture repeats and offset... but these numbers won't make any sense to me (which makes me feel kinda stoopid)...
Could someone explain how to compute these numbers?
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
04-19-2008 06:35
Oskel, nice job, can you add it to the lslwiki.net library?
It has better ways to add code than this :).