Difference between revisions of "NumPad"

From Second Life Wiki
Jump to navigation Jump to search
(Created page and released the first version.)
 
m (added Texture layout info)
Line 93: Line 93:
}
}
</lsl>
</lsl>
==Texture layout==
<p> the texture is setup in a 10x12 format as follows.</p>
<pre>
00 01 02 03 04 05 06 07 08 09
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
_0 _1 _2 _3 _4 _5 _6 _7 _8 _9
0_ 1_ 2_ 3_ 4_ 5_ 6_ 7_ 8_ 9_
</pre>

Revision as of 19:57, 16 January 2013

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>


Texture layout

the texture is setup in a 10x12 format as follows.

00 01 02 03 04 05 06 07 08 09
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
_0 _1 _2 _3 _4 _5 _6 _7 _8 _9
0_ 1_ 2_ 3_ 4_ 5_ 6_ 7_ 8_ 9_