Created
October 4, 2016 04:00
-
-
Save FelixWolf/6f42feef7c2af58fe0029198cab9f55a to your computer and use it in GitHub Desktop.
A simple text on a prim engine for LSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Tiny text engine | |
string __CZChrLst=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; //" | |
list __CZTexLst=["b0f2fc68-94ce-30c5-2d44-e4d104cabff3","1acf3dec-ea5c-3024-bc3c-d97881ac3228","cf9a9675-cac2-7105-c528-7f903c74aa0d","2c5219c6-a781-6a4f-7a1d-7b0b622669a8"]; | |
//Internal function | |
cziSetChars(string _O, integer _L, integer _S){ | |
integer _X=llSubStringIndex(__CZChrLst,llGetSubString(_O,0,0)); | |
integer _Y=llSubStringIndex(__CZChrLst,llGetSubString(_O,1,1)); | |
integer _M=0; | |
if (_X<64&&_Y>64)_M=1; | |
else if(_X>64&&_Y<64)_M=2; | |
else if(_X>64&&_Y>64)_M=3; | |
vector _I=llList2Vector([<64,64,0>,<32,64,0>,<64,32,0>,<32,32,0>],_M); | |
float _W=1/_I.x; | |
float _H=1/_I.y; | |
integer _F=llList2Integer([(64*_X)+_Y,(32*_X)+_Y-64,(64*(_X-64))+_Y,(32*(_X-64))+_Y-64],_M); | |
integer _R=llFloor((float)_F/_I.x); | |
llSetLinkPrimitiveParamsFast(_L,[PRIM_TEXTURE,_S,llList2Key(__CZTexLst,_M),<_W, _H, 0>,<-llFloor(_I.x/2)*_W+_W/2+_W*(_F-_R*_I.x),llFloor(_I.y/2)*_H-_H/2-_H*_R-llList2Float([0.0025,0.0025,0.005,0.005],_M),0>,0]); | |
} | |
list cziSetCharsBuffer(string _O, integer _S){ | |
integer _X=llSubStringIndex(__CZChrLst,llGetSubString(_O,0,0)); | |
integer _Y=llSubStringIndex(__CZChrLst,llGetSubString(_O,1,1)); | |
integer _M=0; | |
if (_X<64&&_Y>64)_M=1; | |
else if(_X>64&&_Y<64)_M=2; | |
else if(_X>64&&_Y>64)_M=3; | |
vector _I=llList2Vector([<64,64,0>,<32,64,0>,<64,32,0>,<32,32,0>],_M); | |
float _W=1/_I.x; | |
float _H=1/_I.y; | |
integer _F=llList2Integer([(64*_X)+_Y,(32*_X)+_Y-64,(64*(_X-64))+_Y,(32*(_X-64))+_Y-64],_M); | |
integer _R=llFloor((float)_F/_I.x); | |
return [PRIM_TEXTURE,_S,llList2Key(__CZTexLst,_M),<_W, _H, 0>,<-llFloor(_I.x/2)*_W+_W/2+_W*(_F-_R*_I.x),llFloor(_I.y/2)*_H-_H/2-_H*_R-llList2Float([0.0025,0.0025,0.005,0.005],_M)-0.001,0>,0]; | |
} | |
//Set the actual text | |
czSetText(integer _L, string _O){ | |
integer _I; | |
for(;_I<8;_I++) cziSetChars(llGetSubString(_O,_I*2,(_I*2)+1),_L,_I); | |
} | |
czSetTextBuffering(integer _L, string _O){ | |
integer _I; | |
list buffer; | |
for(;_I<8;_I++) buffer=buffer+cziSetCharsBuffer(llGetSubString(_O,_I*2,(_I*2)+1),_I); | |
llSetLinkPrimitiveParamsFast(_L,buffer); | |
} | |
list czSetTextBuffer(integer _L, string _O){ | |
integer _I; | |
list buffer=[PRIM_LINK_TARGET,_L]; | |
for(;_I<8;_I++) buffer=buffer+cziSetCharsBuffer(llGetSubString(_O,_I*2,(_I*2)+1),_I); | |
return buffer; | |
} | |
//Just the essentials: | |
//Tiny text engine | |
string __CZChrLst=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; //" | |
list __CZTexLst=["b0f2fc68-94ce-30c5-2d44-e4d104cabff3","1acf3dec-ea5c-3024-bc3c-d97881ac3228","cf9a9675-cac2-7105-c528-7f903c74aa0d","2c5219c6-a781-6a4f-7a1d-7b0b622669a8"]; | |
//Internal function | |
list cziSetCharsBuffer(string _O, integer _S){ | |
integer _X=llSubStringIndex(__CZChrLst,llGetSubString(_O,0,0)); | |
integer _Y=llSubStringIndex(__CZChrLst,llGetSubString(_O,1,1)); | |
integer _M=0; | |
if (_X<64&&_Y>64)_M=1; | |
else if(_X>64&&_Y<64)_M=2; | |
else if(_X>64&&_Y>64)_M=3; | |
vector _I=llList2Vector([<64,64,0>,<32,64,0>,<64,32,0>,<32,32,0>],_M); | |
float _W=1/_I.x; | |
float _H=1/_I.y; | |
integer _F=llList2Integer([(64*_X)+_Y,(32*_X)+_Y-64,(64*(_X-64))+_Y,(32*(_X-64))+_Y-64],_M); | |
integer _R=llFloor((float)_F/_I.x); | |
return [PRIM_TEXTURE,_S,llList2Key(__CZTexLst,_M),<_W, _H, 0>,<-llFloor(_I.x/2)*_W+_W/2+_W*(_F-_R*_I.x),llFloor(_I.y/2)*_H-_H/2-_H*_R-llList2Float([0.0025,0.0025,0.005,0.005],_M)-0.001,0>,0]; | |
} | |
//Set the actual text | |
czSetTextBuffering(integer _L, string _O){ | |
integer _I; | |
list buffer; | |
for(;_I<8;_I++) buffer=buffer+cziSetCharsBuffer(llGetSubString(_O,_I*2,(_I*2)+1),_I); | |
llSetLinkPrimitiveParamsFast(_L,buffer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment