NumPad
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Scripting tools to allow display of text on a prim: XyText 1.5 , XyzzyText, XyyyyzText, XyText-UTF8, XyzzyText-UTF8, ZZText, VariText
NumPad is a variant of the text on a prim but with some changes
- 1 texture vs 5 textures needed for XyText 1.5 'to render numbers'
- Numbers and spaces only.
- About 73 lines of code.
Copyright & Licensing
- Madpeter Zond hereby releases his contributions to this under the MIT license. [Starting texture and Starting code]
NumPad 10digits
Quickstart:
* Take a copy of the 10 char prim setup from [[XyText 1.5]] and setup a prim * After running the code create a new script and copy the NumPad code to it.
Usage:
* Set render_to_prim_number to the number of the prim you wish to render to, * if you dont know the number you can put the script inside of the prim you want * and not change this.
Main Script
<lsl> /*
NumPad
----------------
Version: 1.0
By: Madpeter Zond
About: A 1 texture 10 digit number display
great for a score output.
- /
string texture = "31f72af5-dee3-72f5-3981-bde21bf85e9c"; integer render_to_prim_number = LINK_THIS; vector render_color = <1,1,1>; float glow_amount = 0.00;
// please dont change this unless you want to break something ^_^ list faces = [3,7,4,6,1]; list grid_offset_starts = [<-0.38941,-0.54747,0> ,<-0.44939,-0.54750,0>, <0.01800,0.45256,0>,<-0.44939,-0.54750,0>,<-0.50941,-0.54747,0>]; list repeats_corrections = [<0.1,0,0>,<0,0,0>,<-1.35,0,0>,<0,0,0>,<0.1,0,0>]; vector repeats_config = <0.1,0.083333,0>; float fix(float input) // render blocking fix [haxy] {
if(input > 1.0) input -= 1.0;
else if(input < -1.0) input += 1.0;
return input;
} render(string output) {
while(llStringLength(output) < 10) { output = ""+output+" "; }
list renderrules = [];
integer loop = 0;
while(loop < 5)
{
string part = llGetSubString(output,(2*loop),(2*loop)+1);
if(part == " ")
{
// empty
renderrules = renderrules + [PRIM_COLOR,llList2Integer(faces,loop),<1,1,1>,0,PRIM_GLOW,llList2Integer(faces,loop),0];
}
else
{
integer Y_offset = (integer)llGetSubString(part,0,0);
integer X_offset = (integer)llGetSubString(part,1,1);
if(llGetSubString(part,0,0) == " ") Y_offset = 11; // left side empty
else if(llGetSubString(part,1,1) == " ") Y_offset = 12; // right side empty
vector start = llList2Vector(grid_offset_starts,loop);
start = <fix(start.x + (0.1 * X_offset)),fix(start.y + (-0.083333333 * Y_offset)),0>;
renderrules = renderrules + [PRIM_TEXTURE,llList2Integer(faces,loop),texture,repeats_config+llList2Vector(repeats_corrections,loop),start,0,PRIM_COLOR,llList2Integer(faces,loop),render_color,1,PRIM_GLOW,llList2Integer(faces,loop),glow_amount];
}
loop++;
}
llSetLinkPrimitiveParamsFast(render_to_prim_number,renderrules);
} default {
state_entry()
{
render("1234567890");
}
} </lsl>